Hi here is the code for your problem
$con = mysql_connect("hostname","mysql username","mysql password");
mysql_select_db("databse name",$con);
$query = "SELECT * FROM members";
$checklogin = mysql_query($query);
while($res = mysql_fetch_array($checklogin,MYSQL_ASSOC)) {
$result[] = $res;
}
the results will have the details
so now you can loop the results and you can check the conditions as your wish.
Let me know if you need in detail code i will provide.