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

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -