I have an array of numbers which is $friendid, and what I would like to find all members with those id's and display them in order by 'points' which is a column in my users table. However I can't just do a basic query doing a foreach, because while the returns each individual user from my databaseI can't do "ORDER BY points DESC" because it only has one row at a time, so it has nothing to order it by. So someone told me I should do it by doing...

$friendid = $friend['id'];
$ps = $pdo->prepare("SELECT name, points FROM users WHERE id = ?");
$ps->bindParam(1, $friendid);
$ps->setFetchMode(PDO::FETCH_ASSOC);
$res = array();
foreach ($friendids as $friendid)
{
$ps->execute();
$res[] = $ps->fetch();
}

and then applying "array_multisort()" or "assort()" to "$res" but I have no idea how to get this to work, and I don't know what I'm supposed to put in the id = ? (since I seriously doubt that should be a questionmark.

So can anyone tell me how I'd go about doing this? How is it I can pull all users in the $friendid array, and then order by points. Any help would be greatly appreciated.