note 57933 added to function.mysql-field-name
| From: | janezratjcndotsi at osu1 dot php dot net | Date: | Wed, 19 Oct 2005 14:18:50 +0000 |
| Subject: | note 57933 added to function.mysql-field-name | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-97231@lists.php.net to get a copy of this message | ||
This is another variant of displaying all columns of a query result, but with a simplified while
loop.
<?
$query="select * from user";
$result=mysql_query($query);
$numfields = mysql_num_fields($result);
echo "<table>\n<tr>";
for ($i=0; $i < $numfields; $i++) // Header
{ echo '<th>'.mysql_field_name($result, $i).'</th>'; }
echo "</tr>\n";
while ($row = mysql_fetch_row($result)) // Data
{ echo
'<tr><td>'.implode($row,'</td><td>')."</td></tr>\n";
}
echo "</table>\n"
?>
----
Manual Page -- http://www.php.net/manual/en/function.mysql-field-name.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+57933
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+57933&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+57933&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+57933&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+57933&report=yes&reason=useless
Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+57933&report=yes&reason=non-english
Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+57933&report=yes&reason=already+in+docs
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+57933&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+57933&report=yes
Search -- http://master.php.net/manage/user-notes.php