note 62394 added to function.mysql-fetch-field
| From: | jordan dot ledoux at gmail dot com | Date: | Mon, 27 Feb 2006 18:44:39 +0000 |
| Subject: | note 62394 added to function.mysql-fetch-field | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-104504@lists.php.net to get a copy of this message | ||
Here's a function which compiles an array out of a mysql query for any number of columns using
this function:
<?
function compile_array($mysql) {
$i = 0;
while ($field = mysql_fetch_field($mysql)) {
/* Create an array $fields which contains all of the column names */
$fields[$i] = $field->name;
$i++;
}
$i = 0;
while ($mysql_result = mysql_fetch_array($mysql)) {
foreach ($fields as $val) {
/* Compiles an array in the format:
$data [ row number ] [ column name ] */
$data[$i][$val] = $mysql_result[$val];
}
$i++;
}
return $data;
}
?>
----
Server IP: 216.194.113.175
Probable Submitter: 159.191.249.252
----
X-Spam-Status: No, hits=3.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER
autolearn=no version=2.64
----
Manual Page -- http://www.php.net/manual/en/function.mysql-fetch-field.php
Edit -- http://master.php.net/note/edit/62394
Del: integrated -- http://master.php.net/note/delete/62394/integrated
Del: useless -- http://master.php.net/note/delete/62394/useless
Del: bad code -- http://master.php.net/note/delete/62394/bad+code
Del: spam -- http://master.php.net/note/delete/62394/spam
Del: non-english -- http://master.php.net/note/delete/62394/non-english
Del: in docs -- http://master.php.net/note/delete/62394/in+docs
Del: other reasons-- http://master.php.net/note/delete/62394
Reject -- http://master.php.net/note/reject/62394
Search -- http://master.php.net/manage/user-notes.php