Monday, December 16, 2013

Fetch All Rows from table drupal 7

 <select class="form-select formbox3" name="field_country"><?php 
$result = db_query('SELECT * FROM {countries_country}');
// Result is returned as a iterable object that returns a stdClass object on each iteration
foreach ($result as $record) {
?>
   
 <option value="<?php print $record->iso2;?>" <?php if($profile->field_country['und'][0]['value'] == $record->iso2) { ?> selected="selected" <?php } ?>><?php print $record->name;?></option>
   
   <?php
}
?>
</select>

No comments:

Post a Comment