My question is simnple. I want to randomly select a row in a mysql
table. I have a primary id.
?php
$server = localhost;
$user = foo;
$pass = foo;
$db=foo_db;
$table=foo_table;
$myconnection = mysql_connect($server,$user,$pass);
mysql_select_db($db,$myconnection);
$sql = ??;
$news =
John Taylor-Johnston wrote:
My question is simnple. I want to randomly select a row in a mysql
table. I have a primary id.
?php
$server = localhost;
$user = foo;
$pass = foo;
$db=foo_db;
$table=foo_table;
$myconnection = mysql_connect($server,$user,$pass);
mysql_select_db($db,$myconnection);
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.
?php
$server = localhost;
$user = foo;
$pass = foo;
$db=foo_db;
$table=foo_table;
$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
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
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 to
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
7 matches
Mail list logo