php-db | 2002122
Date: 12/17/02
- Next message: Jason Wong: "Re: [PHP-DB] random rows...what about tables"
- Previous message: Anthony Carlos: "[PHP-DB] Oracle/PHP question..."
- Next in thread: Jason Wong: "Re: [PHP-DB] random rows...what about tables"
- Reply: Jason Wong: "Re: [PHP-DB] random rows...what about tables"
- Reply: Wico de Leeuw: "Re: [PHP-DB] random rows...what about tables"
- Maybe reply: Hutchins, Richard: "RE: [PHP-DB] random rows...what about tables"
- Maybe reply: Matthew Moldvan: "RE: [PHP-DB] random rows...what about tables"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Bruce Levick - Vivamotion
Been searching for an answer to selecting a random table and then a random
row within the selected table.
I have this code which successfully selects a random row within a hard coded
table. But just can't get the random table working.
<?php
//trying to select all tables from the database portfolio........pfff
$alltables = mysql_list_tables("portfolio");
//trying to get the array value of the alltables...there are 4 tables in the
database. So as far as I know the value of $alltables should be 3. (0table,
1table, 2table, 3table)
$randtabnum = array($alltables);
// this selects everything from the Illustrations table. I need to make the
FROM table_name a random selection
$all = mysql_query("SELECT * FROM Illustrations");
//acquires total rows
$totalRows_Recordset1 = mysql_num_rows($all);
// selects random row from total rows
$rndm = mysql_query("SELECT * FROM Illustrations ORDER BY RAND() LIMIT
4,$totalRows_Recordset1");
if (!$rndm) {
echo("<P>Error performing query: " .
mysql_error() . "</P>");
exit();
}
$randrow = mysql_fetch_array($rndm);
?>
Anybody see the solution??
Winxp Pro, php 4.2.2 Mysql 3.2
Cheers
-- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
- Next message: Jason Wong: "Re: [PHP-DB] random rows...what about tables"
- Previous message: Anthony Carlos: "[PHP-DB] Oracle/PHP question..."
- Next in thread: Jason Wong: "Re: [PHP-DB] random rows...what about tables"
- Reply: Jason Wong: "Re: [PHP-DB] random rows...what about tables"
- Reply: Wico de Leeuw: "Re: [PHP-DB] random rows...what about tables"
- Maybe reply: Hutchins, Richard: "RE: [PHP-DB] random rows...what about tables"
- Maybe reply: Matthew Moldvan: "RE: [PHP-DB] random rows...what about tables"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

