mysql_fetch_array problem
| From: | René Fournier | Date: | Mon, 15 Oct 2001 20:03:01 +0000 |
| Subject: | mysql_fetch_array problem | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-71137@lists.php.net to get a copy of this message | ||
A 'simple' problem that's driving me insane: I want to randomly select one
row out of a table (one condition: WHERE lang='$lang'). It seems that
$mytestimonial selects just the first row it finds (not all) from the
table--so it's not a multidimensional array, which I want it to be (unless
there's another way to grab a random row from the table--I figured I would
have select all possible rows, then select one randomly). Here's the crux of
the problem code...
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
$numrows = mysql_num_rows(mysql_query("SELECT * FROM testimonials WHERE
lang='$lang'",$db));
$mytestimonial = mysql_fetch_array(mysql_query("SELECT * FROM testimonials
WHERE lang='$lang'",$db));
$which = rand(0,$numrows-1);
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Any help you can give will be greatly appreciated.
...Rene
---
Rene Fournier
renefournier@yahoo.com