# Php retrieve field name

**URL:** <https://forum.kirupa.com/t/php-retrieve-field-name/230689>\
**Category:** Uncategorized\
**Created:** [June 28, 2007, 8:31am UTC](https://forum.kirupa.com/t/php-retrieve-field-name/230689 "2007-06-28T08:31:29Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![kitaeshi](https://avatars.discourse-cdn.com/v4/letter/k/9f8e36/32.png) [@kitaeshi](https://forum.kirupa.com/u/kitaeshi)\
**Post date:** [June 28, 2007, 8:31am UTC](https://forum.kirupa.com/t/php-retrieve-field-name/230689/1 "2007-06-28T08:31:29Z")

</div>

Hi all i found this code in the book, but it only display the value, i need to show the field with the value. how to go abt changing the code? i know have to do with =\> or -\>.  
tks.

$result = mysql\_query(“SELECT\* FROM tb2”);  
$num\_field = mysql\_num\_fields($result);

print “There are $num\_row in the table\<p\>”;  
print "\<table border=1\>  
";  
while($a\_row = mysql\_fetch\_row($result)){  
print "\<tr\>  
";  
foreach($a\_row as $field))  
print " \<td\>$field\</td\>  
";  
print "\</tr\>  
";  
}  
print "\</table\>  
"
