I need help with outputting mysql data into a drop menu.
How can I go about that? Because Im only getting one row in my loop.
Should I put the data into an array and then print them in the dropdown option?
...something like this:
while($var = mysql_fetch_assoc($result)){ echo $var['field']; }
Originally posted by bodzan ...something like this: while($var = mysql_fetch_assoc($result)){ echo $var['field']; }
Yea, but won't I lose the previous values the next time Im in the loop.
I need two dropdown menus which have the same values in it.
Any help
then use an array
while ($row = mysql_fetch_assoc($result)) { $array[] = $row['field']; } foreach($array as $value) { echo 'html stuff for dropdowns' . $value; } foreach($array as $value) { echo 'htmlstuff for dropdown#2' . $value; }
something like that what you want?
Ill try this
while ($row = mysql_fetch_assoc($result)) { $option_block = $option_block."<option value=\"{$row['blah1']}\">{$row['blah2']}</option>"; } echo "<select name=\"my select\">$option_block</select>";