Need to display results randomly on mysql 3.22!
| From: | Sandeep Hundal | Date: | Thu, 14 Dec 2000 03:55:56 +0000 |
| Subject: | Need to display results randomly on mysql 3.22! | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-30237@lists.php.net to get a copy of this message | ||
Hi all!!
I have a fairly painful PHP problem. I'm trying to randomize the
result I get from my table. Problem is that its not on MySQL 3.23 so
I cant use the RAND() function :(
If I cant use SQL to randomize my query, how can I use PHP? I've
tried some parts of the manual but couldnt find anything which I
could make into an answer :(
Below is the code I use.
TIA!
<?
$query = SELECT id, companytitle, description
FROM table
WHERE blah=blah
GROUP BY blah2
ORDER BY id
LIMIT 20 ");
$number = "1";
if ($result2) {
while ($r2 = mysql_fetch_array($result2)) {
extract($r2);
echo "
$number. $companytitle
$description
<a href=/frameset.php?id=$id>Click here</a>
<br>
";
$number++;
}
}
mysql_free_result($result2);
?>
__________________________________________________
Do You Yahoo!?
Yahoo! Shopping - Thousands of Stores. Millions of Products.
http://shopping.yahoo.com/