;D hi again i am trying to select a random user from the database by there id ($userID) but i want to ensure that the id does not refer to the current user ($_SESSION[‘SESS_MEMBER_ID’]) also the member must belong to the same class and have done the same test ($testID). i know i will need the order by rand function but i cant seem to get it to work.
[php]$sql = “SELECT * FROM Test
ORDER BY RAND()
LIMIT 1”;[/php]
[php]$sql = “SELECT * FROM Test
WHERE Test.testID=’$testID’ AND Test.userID != ‘$userID’
ORDER BY RAND()
LIMIT 1”;[/php]
Should do the trick!
cheers it was the where clause i had it in the wrong place