I have a table that with the fields ID, workerID and photo. Each worker can have multiple photos but I need a query to grab one of each worker randomly, so that only one photo is shown of each worker in a gallery, and in random order. I have this code but it is only grabbing the first instance of each worker and then displaying the photos in that order.
Any suggestions would be greatly appreciated
Code:
$sql = mysql_query("SELECT ID
FROM tblworker");
while(list($workerID)=mysql_fetch_row($sql)){
$get = mysql_query("SELECT photo
FROM tblphoto
WHERE workerID = '$workerID'
ORDER BY RAND() LIMIT 1");
list($workerID, $photo)=mysql_fetch_row($get);
}//end while