Re: [PHP] random row

2005-11-15 Thread Curt Zirzow
On Wed, Nov 16, 2005 at 05:19:52PM +1300, Jasper Bryant-Greene wrote: > John Taylor-Johnston wrote: > >My question is simnple. I want to randomly select a row in a mysql > >table. I have a primary id. > > > > >$server = "localhost"; > >$user = "foo"; > >$pass = "foo"; > >$db="foo_db"; > >$table="f

Re: [PHP] random row

2005-11-15 Thread Jasper Bryant-Greene
John Taylor-Johnston wrote: My question is simnple. I want to randomly select a row in a mysql table. I have a primary id. $news = mysql_query($sql) or die(print "color=red>".mysql_error().""); while ($mydata = mysql_fetch_object($news)) { ?? } ?> If your table isn't too big, it's

[PHP] random row

2005-11-15 Thread John Taylor-Johnston
My question is simnple. I want to randomly select a row in a mysql table. I have a primary id. $news = mysql_query($sql) or die(print "color=red>".mysql_error().""); while ($mydata = mysql_fetch_object($news)) { ?? } ?> -- PHP General Mailing List (http://www.php.net/) To unsubscribe,

Re: [PHP] Random Row...

2003-01-16 Thread Danny Shepherd
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..

[PHP] Random Row...

2003-01-16 Thread Brian McGarvie
$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? --- Outgoing mail is certified

Re: [PHP] Random Row From Database

2001-11-11 Thread Christian Reiniger
On Sunday 11 November 2001 05:18, HEW Staff wrote: > Hi, > > I'm trying to pull a random row from my database and display the > contents. > > I know that the code: > SELECT * FROM TABLENAME WHERE RAND() LIMIT 1 > should work. (1) [EMAIL PROTECTED] has nothing to do with this. So don't crosspost t

[PHP] Random Row From Database

2001-11-10 Thread HEW Staff
Hi, I'm trying to pull a random row from my database and display the contents. I know that the code: SELECT * FROM TABLENAME WHERE RAND() LIMIT 1 should work. However, there are 19 rows in the database and only the first row ever shows up. Is there a way to do this to ensure uniqueness? The c