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
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
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,
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?
---
Outgoing mail is certified
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
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
7 matches
Mail list logo