Discussion

Welcome to Absolute Web Dev Forum. Feel free to Register and ask me a question about web development or, if you can answer or contribute to the aswering of someones question, feel free to respond. All listings are reviewed by me so please make your comments usefull. If you will, please leave links to related websites or other references that someone can go to for further information on a given subject. Thank you for your contribution to Absolute Web Devs Web Forum.Create Discussion

How do I get the field names in my database to display?

Incognito

How do I get the field names in my database to display?   -   03/05/2009


I am trying to get the field names from my database so I can make a function for different tables. This function will get the field names from different tables and place those field names into my SQL statement. I guess I just don’t know where to begin on this. :(

WebMaster

Response   -   03/05/2009


This is a simple way to retrieve field names from your database.

$sql = "SELECT * from $database";
$result = mysql_query($sql,$dbc);

$field0 = mysql_field_name($result, 1);
$field1 = mysql_field_name($result, 2);
$field2 = mysql_field_name($result, 3);

echo '
Field Names:<br />
'.$field0.'<br />
'.$field1.'<br />
'.$field2.'<br />';

You can also visit the MySQL manual for more details at the following link.


http://us3.php.net/mysql_field_name


Add to this Discussion

Discussion Archive


TOP

  100% compatible with:
Firefox Explorer Opera Safari Flock Netscape Chrome

 100% valid CSS 3.0 and XHTML 1.0.
Valid CSS Valid XHTML