|
Development -
PHP
|
|
Written by Rick
|
|
Monday, 14 July 2008 17:00 |
|
On occassion we need to get the Row names in a table. The following code snippet shows how to connect to the database and display all the Row names in the database table.
 $con = mysql_connect(DB_HOST,DB_USER,DB_PASSWORD);    mysql_select_db(DB_NAME, $con);    $sql="Select * FROM DB_TABLENAME";    $result = mysql_query($sql,$con) or die(mysql_error());    $rowcount=mysql_num_rows($result);    $y=mysql_num_fields($result);       for ($x=0; $x<$y; $x++) {            echo mysql_field_name($result, $x).'<br>';       }    mysql_close($con); |
|