note 78811 added to function.mysql-list-fields
| From: | perwool at seznam dot cz | Date: | Mon, 29 Oct 2007 10:32:39 +0000 |
| Subject: | note 78811 added to function.mysql-list-fields | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-131805@lists.php.net to get a copy of this message | ||
Every my html table output begins with heading row containing the field names. For that purpose I
accepted the short combination of MySQL function, giving me a result similar to the
mysql_fetch_array() for the row of values. The following example shows the basic idea. It should be
adapted for the specific use:
<?php
//...
$field_names = array_keys( mysql_fetch_array( mysql_query( $query, $link), MYSQL_ASSOC));
//...
?>
The advantage of this is, that it gives the names of the result, neither the field names of the
whole table.
Please read the discussion about duplicate field names in SQL result carefully. The use, as shown in
the example above, increments the pointer, hence some regular function, which does not, could be
more useful :-)
Jan
----
Server IP: 69.147.83.197
Probable Submitter: 85.207.146.34
----
Manual Page -- http://www.php.net/manual/en/function.mysql-list-fields.php
Edit -- https://master.php.net/note/edit/78811
Del: integrated -- https://master.php.net/note/delete/78811/integrated
Del: useless -- https://master.php.net/note/delete/78811/useless
Del: bad code -- https://master.php.net/note/delete/78811/bad+code
Del: spam -- https://master.php.net/note/delete/78811/spam
Del: non-english -- https://master.php.net/note/delete/78811/non-english
Del: in docs -- https://master.php.net/note/delete/78811/in+docs
Del: other reasons-- https://master.php.net/note/delete/78811
Reject -- https://master.php.net/note/reject/78811
Search -- https://master.php.net/manage/user-notes.php