Hi all, I'm a php newbie and have read various posts/articles on populating select lists dynamically from a db table. However, I cant seem to get it working in the way I want...
I have 3 select lists on a form and want to use a single piece of code to display each one by passing the relevant query to the code. My problem is that I dont know which mysql_fetch command to use because I cannot access each item by name only number (as the name will change depending on which table I use).
Which loop structure is best?
Currently I'm using...
$country_query = "select coutry_name from country";
$countrys = $conn->query($country _query);
$country_list = mysqli_fetch_ob ject($countrys)
...
case "Country":
$select_list = $country_list;
break;
...
foreach ($select_list as $eachitem) {
?>
<option value="<?php echo $eachitem ?>"> etc.
<?php } ?>
...
Which only gives me one item in each of the select boxs!!! where r the others? How can I get all the countries listed?
Thanks in advance!
I have 3 select lists on a form and want to use a single piece of code to display each one by passing the relevant query to the code. My problem is that I dont know which mysql_fetch command to use because I cannot access each item by name only number (as the name will change depending on which table I use).
Which loop structure is best?
Currently I'm using...
$country_query = "select coutry_name from country";
$countrys = $conn->query($country _query);
$country_list = mysqli_fetch_ob ject($countrys)
...
case "Country":
$select_list = $country_list;
break;
...
foreach ($select_list as $eachitem) {
?>
<option value="<?php echo $eachitem ?>"> etc.
<?php } ?>
...
Which only gives me one item in each of the select boxs!!! where r the others? How can I get all the countries listed?
Thanks in advance!
Comment