web 2.0

How to use PHP & MySQL Get Field Name

How to use PHP & MySQL Get Field Name Learn PHP how to using PHP get field name from a mysql database table.

ShotDev Focus:
- PHP & MySQL get field name from table.

Example

php_list_table.php


<html>
<head>
<title>ShotDev.Com Tutorial</title>
</head>
<body>
<?
$objConnect = mysql_connect("localhost","root","root") or die(mysql_error());
$objDB = mysql_select_db("mydatabase");
$strSQL = "SELECT * FROM customer";
$objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");
$intNumField = mysql_num_fields($objQuery);
$i = 0;
echo "<b>Table customer have $intNumField Fields.</b><br>";
for($i=1;$i<$intNumField;$i++)
{
echo $i."=".mysql_field_name($objQuery,$i)." (".mysql_field_type($objQuery,$i).")<br>";
}

mysql_close($objConnect);
?>
</body>
</html>

Create a php file and save to path root-path/myphp/

Run
http://localhost/myphp/php_list_table.php

Screenshot

PHP MySQL Get Table Properties
.
.
.

Download this script.
Download

1 Star2 Stars3 Stars4 Stars5 Stars6 Stars7 Stars8 Stars9 Stars10 Stars (1 votes, average: 1.00 out of 10)
Loading ... Loading ...

Leave a Reply

You must be logged in to post a comment.