php - How to parse query row into arrays? -
i have php login sytem in use following query compare username , password:
$mquery = $mysqli->query("select * users user = '" . $mysqli->real_escape_string(md5($_post['user'])) ."' , pass= '" . $mysqli->real_escape_string(md5($_post['pass'])) . "'");
there other fields in user row besides 'user' , 'pass', 'name' , 'email'. how can these fields array?
in php 5.3 , later, fetch_all
return rows array. if specify mysqli_assoc result type, each element in array associative array of fields, indexed name.
// having done query above $rows = $mquery->fetch_all(mysqli_assoc); foreach ($rows $row) { print "email: " . $row['email'] . "<br />"; // etc }
for earlier versions, you'd manually:
$rows = array(); while ($row = $mquery->fetch_array(mysqli_assoc)) $rows[] = $row; foreach ($rows $row) { print "email: " . $row['email'] . "<br />"; // etc }
Comments
Post a Comment