Re: random rows...what about tables
| From: | Bruce Levick | Date: | Tue, 17 Dec 2002 14:18:46 +0000 |
| Subject: | Re: random rows...what about tables | ||
| References: | 1 2 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-24227@lists.php.net to get a copy of this message | ||
Sorry,
Have updated my script with a little help. Upon output i am recieving this.
Warning: Argument to array_rand() has to be an array in
C:\WORKING\portfolio\vivamotion\site\php\request.php on line 51
this is the code below.
////////////////////////////////////////////////////////////////////////////
/////
<?php
//listing table in database
$alltables = mysql_list_tables("portfolio");
//random array
$randomtable = array_rand($alltables);
$all = mysql_query("SELECT * FROM Illustrations");
$totalRows_Recordset1 = mysql_num_rows($all);
$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);
?>
//output to browser
<?php
print "$randomtable\n";
?>
Hope that helps
----- Original Message -----
From: "Jason Wong" <php-db@gremlins.biz>
To: <php-db@lists.php.net>
Sent: Tuesday, December 17, 2002 11:48 PM
Subject: Re: [PHP-DB] random rows...what about tables
> On Tuesday 17 December 2002 21:38, Bruce Levick wrote:
> > 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.
>
> [snip]
>
> > Anybody see the solution??
>
> First we need to know _what_ the problem is. I think we can assume your
code
> doesn't work the way you expected. Can you tell us _how_ it doesn't work?
> Error messages?
>
> --
> Jason Wong -> Gremlins Associates -> www.gremlins.biz
> Open Source Software Systems Integrators
> * Web Design & Hosting * Internet & Intranet Applications Development *
>
>
> /*
> We place two copies of PEOPLE magazine in a DARK, HUMID mobile home.
> 45 minutes later CYNDI LAUPER emerges wearing a BIRD CAGE on her head!
> */
>
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>