Jump to content

order by and limits


fife

Recommended Posts

Hi.  Right I'm trying to write a little script that selects one random image from a group and displays it on the page.  Here is my code...

$TheCat = $data['album_name'];
$GetAPicy = "SELECT photo_name, album FROM photos WHERE album = '$TheCat'  ORDER BY rand LIMIT 1"; 
$rGetAPicy = mysql_query($GetAPicy) or die(mysql_error());
$Picy = mysql_fetch_array($rGetAPicy);

 

With this code I get the following error

 

                        Unknown column 'rand' in 'order clause'

 

Obviously I can see the error but I dont understand where they are supposed to be placed.  Can anyone help?

Link to comment
https://forums.phpfreaks.com/topic/226342-order-by-and-limits/
Share on other sites

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.