NYCPHP Meetup

NYPHP.org

learning about foreach() continued

Joshua S. Freeman jfreeman at amnh.org
Wed May 21 15:37:50 EDT 2003


Thanks for everyone who's chimed in so far... I appreciate the various code
snippets but I'm trying to see if I can do everything I need here using
'foreach()'...

so.. 

since this:

$query= mysql_query("select * FROM taxa_order");

  $result = mysql_fetch_assoc($query);
        print ("<select name=\\"order\\">");
        foreach ($result as $key=>$val)
        print "<option value=\\"$key\\">$val</option>";
        print ("</select>");

yields this:

<select name="order"><option value="order_id">1</option><option
value="order_name">Hymenoptera</option></select>

how do I get it to stop from creating two <option></option> rows (there's
only one row in the table!) and how do I get it to stop from including the
names of the columns and just including the value for each column in the one
row?

J.




More information about the talk mailing list