[nycphp-talk] learning about foreach continued
max goldberg
max at idsociety.com
Wed May 21 15:48:07 EDT 2003
>From www.php.net/mysql
The function mysql_fetch_array() uses a constant for the different types
of result arrays. The following constants are defined:
Table 3. MySQL fetch constants
constant description
MYSQL_ASSOC Columns are returned into the array having the fieldname as
the array index.
MYSQL_BOTH Columns are returned into the array having both a numerical
index and the fieldname as the array index.
MYSQL_NUM Columns are returned into the array having a numerical index
to the fields. This index starts with 0, the first field in the result.
More at http://www.php.net/manual/en/function.mysql-fetch-array.php
-max
Joshua S. Freeman wrote:
> 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.
>
>
>
> --- Unsubscribe at http://nyphp.org/list/ ---
>
>
More information about the talk
mailing list