View Single Post
  #6  
Old 06-04-2008, 02:14 PM
Jackaal Jackaal is offline
Private
 
Join Date: Jun 2008
Location: Australia
Posts: 4
Default Re: how to fill combobox with dynamic php variables ?

I am a novice at this sort of thing but i have learnt a great deal from this post. I have adapted the code you offered and it seems to work by adding as many entries into the combo box as there are in the database however, they appear blank. Any help would be much appreciated.

Example

Quote:
<?
require ("actdb.php");
$query = "SELECT name FROM combatant_table WHERE damage!=0 AND ally='T'";
$result = mysql_query($query);
while ($row = mysql_fetch_array($result)) {
$name[] = $row['name'];
}

?>
<select name="name" size="1" id="Combobox1">
<?
$option = "<option value=\"Please select a Category\">Please select a Category</option> \n";
for ($i = 0; $i < count($name); $i++) {
$option .= "<option ";
$option .= "value=\"$name[$i]\">$name[$i]</option> \n"; }
echo $option;
?>
</select>
Reply With Quote