I have a database table named “author” and when someone sign up and then visit his profile I want to show result like
Name : user name here
Email : email here
location : location here
Location, email and name are database column names. I can retireve the database value but I can not retieve the database column names. How can i do that?
Update:
Here is my code
$query = "SELECT *
FROM author
WHERE id = {$author_id};
$author_info = mysql_query($query, $connection);
$author_details = mysql_fetch_assoc($author_info);
foreach ($author_details as $fieldname) {
echo $fieldname;
}
From this code i get only the value of name, location, email but i also need to print column names like name, email, location along with their column values.
mysql_field_name($index)Okay, let’s suppose you already ran the query to get your data. this is how you can create a table with those data as you want. Or just use
mysql_field_name($index)as you want. with this example you’ll get the idea.