Re: [PHP] mysql_fetch_array problem From: Mark (maggelet <email protected>)
Date: 10/14/01

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 <email protected> on 10/14/2001

-- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-general-unsubscribe <email protected> For additional commands, e-mail: php-general-help <email protected> To contact the list administrators, e-mail: php-list-admin <email protected>