I am not sure what function to use for my while loop. I am trying to get the while loop to pick either male or female depending on the choose the user made at login. The user is gender and looking_for is suppose to display either male or female. Right now it is showing all users in the db. It actually shows all the male then followed by all the females so I think it is almost there. I used the order by as the where was not working at all.
$sql2 = mysql_query("SELECT * FROM Members ORDER BY looking_for LIMIT $pn, $itemsPerPage");
$outputList = '';
while($row = mysql_fetch_array($sql2)) {
$valid = array( 'Male', 'Female');
$id = $row["id"];
$looking_for=$row["looking_for"];
$firstname = $row["firstname"];
if (!$firstname) {
$firstname = $looking_for;
foreach($valid as $key => $value);
}