Don't make life difficult for yourself :)

SELECT * FROM myTable ORDER BY RAND() LIMIT 0,1

HTH

Danny.

----- Original Message ----- 
From: "Brian McGarvie" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, January 16, 2003 9:37 AM
Subject: [PHP] Random Row...


> $sql = "
>     select count(*) as theCount
>     from myTable
> ";
> ...
> $row_id = rand(1, $myrow["theCount"]);
> ...
> $sql_randow_row "
>     select *
>     from myTable
>     where id = $row_id
> ";
> 
> I assume I'm right with the method above to select a random row? or any
> other way?
> 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to