note 55518 added to function.mysql-field-name
| From: | clinnenb at hotmail dot com | Date: | Fri, 05 Aug 2005 15:19:10 +0000 |
| Subject: | note 55518 added to function.mysql-field-name | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-93137@lists.php.net to get a copy of this message | ||
The following will create a PHP array, $array, containing the MySQL query results with array indexes
of the same name as field names returned by the MySQL query.
while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
$i=0;
foreach ($line as $col_value) {
$field=mysql_field_name($result,$i);
$array[$field] = $col_value;
$i++;
}
}
----
Manual Page -- http://www.php.net/manual/en/function.mysql-field-name.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+55518
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+55518&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+55518&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+55518&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+55518&report=yes&reason=useless
Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+55518&report=yes&reason=non-english
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+55518&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+55518&report=yes
Search -- http://master.php.net/manage/user-notes.php