Jump to content

[SOLVED] SQL SELECT + random


chocopi

Recommended Posts

cheers taith but it wasnt working so i put mysql_error in there and it returned:

 

You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'LIMIT 1' at line 1

 

egorig, thanks i shall try yours in a mo

 

~ Chocopi

thanks for all your help guys, but

 

this is what i ended up with:

 

<?php
$query = mysql_query("SELECT id FROM table WHERE id>0 ORDER BY rand() LIMIT 1");
$row = mysql_fetch_assoc($query) or die(mysql_error());
$blah = $row['id'];
echo $blah;
?>

 

However it is only returning 1 and none of the other values

 

~ Chocopi

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.