note 83599 modified in function.mysql-fetch-field by danbrown

From: Date: Sat, 20 Jun 2009 02:13:56 +0000
Subject: note 83599 modified in function.mysql-fetch-field by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-157154@lists.php.net to get a copy of this message
Simple PHP script for displaying the field names. Presuming the database is seleected already. <?php $sql = "SELECT * FROM table_name;"; $result = mysql_query($sql); $i = 0; while($i<mysql_num_fields($result)) { $meta=mysql_fetch_field($result,$i); echo $i.".".$meta->name."<br />"; $i++; } ?> OUTPUt: 0.id 1.todo 2.due date 3.priority 4.type 5.status 6.notes hope this is useful. --was-- Simple PHP script for displaying the field names. Presuming the database is seleected already. $sql = "SELECT * FROM table_name;"; $result = mysql_query($sql); $i = 0; while($i<mysql_num_fields($result)) { $meta=mysql_fetch_field($result,$i); echo $i.".".$meta->name."<br />"; $i++; } OUTPUt: 0.id 1.todo 2.due date 3.priority 4.type 5.status 6.notes hope this is useful. http://php.net/manual/en/function.mysql-fetch-field.php

« previous php.notes (#157154) next »