note 46458 deleted from function.mysql-fetch-row by philip

From: Date: Mon, 26 Feb 2007 06:54:09 +0000
Subject: note 46458 deleted from function.mysql-fetch-row by philip
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-123870@lists.php.net to get a copy of this message
Note Submitter: girish dot sonawane at gmail dot com ---- Here's a modified version of Jame's set_variables_after_query() The modified version returns an array of hashes containing all the records... function set_array_from_query($qry) { $arr = array(); $selection = mysql_query($qry); if (!$selection) { die('Invalid query: ' . mysql_error()); } if (mysql_num_rows($selection) > 0) { $x=0; // iterate through resultset while($row = mysql_fetch_row($selection)) { foreach($row as $i => $value) { $column = mysql_field_name($selection,$i); $data["$column"] = $value; $arr[$x] = $data; } $x++; } } return $arr; } //Examples $array = set_array_from_query("select * from SomeTable");

« previous php.notes (#123870) next »