Re: mysql_fetch_array problem
| From: | Mark | Date: | Sun, 14 Oct 2001 20:25:17 +0000 |
| Subject: | Re: mysql_fetch_array problem | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-71139@lists.php.net to get a copy of this message | ||
On Mon, 15 Oct 2001 14:03:01 -0600, René Fournier wrote:
>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));
try adding 'order by rand() limit 1' to the end of the query
--
Mark, maggelet@mminternet.com on 10/14/2001