RE: help: column into array?
| From: | Tim Ward | Date: | Mon, 12 Feb 2001 09:50:27 +0000 |
| Subject: | RE: help: column into array? | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-39195@lists.php.net to get a copy of this message | ||
if ($result = mysql_db_query($database, $sql, $link_id);)
{ while ($thisrow = mysql_fetch_array($result))
{ $array[] = $thisrow("field");
};
};
... or something like that
Tim Ward
Senior Systems Engineer
Please refer to the following disclaimer in respect of this message:
http://www.stivesdirect.com/e-mail-disclaimer.html
> -----Original Message-----
> From: andrew [mailto:andrew@salamander.net]
> Sent: 12 February 2001 05:52
> To: PHP General
> Subject: help: column into array?
>
>
> Hi PHPers!
>
> how can I reference a result set by array index numbers???
>
> this $sql="select field from table where id_field = 1";
> would return a result like this:
>
> field
> -----------
> first
> second
> third
>
> from this table
>
> id_field field
> --------|--------
> 1 first
> 1 second
> 1 third
> 2 fourth
> 2 fifth
>
> how can I do something like this:
>
> $array=mysql_db_query($database, $sql, $link_id);
>
> echo array[0]; //I want this to print "first"
> echo array[1]; //I want this to print "second"
>
> I know mysql_fetch_array pulls a ROW into an array, but in
> this case the row
> is only one item wide, so I essentially want column results
> in an indexed
> array.
>
> TIA!
> andrew
>
>
>