Query into Array


/ Published in: PHP
Save to your folder(s)



Copy this code and paste it in your HTML
  1. function query_into_array($query){
  2. settype($retval,"array");
  3. $result= mysql_query($query);
  4. $y=mysql_num_rows($result);
  5. $k=mysql_num_fields($result);
  6. for($i=0;$i<$y;$i++){
  7. for($j=0;$j<$k;$j++){
  8. $retval[$i][mysql_field_name($result,$j)] = mysql_result($result,$i, mysql_field_name($result,$j));
  9. }
  10. }
  11. return $retval;
  12. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.