How to show the logged in users data?

So I have this line of code here…

$fetch_users_data = mysql_fetch_object(mysql_query("SELECT * FROM `users` WHERE `username`='".$user_data."'"));

It gets the logged in users data from the table “users”.

My question is how do I extract the users information into a code so it can show on their account page?

<? echo “???” ?>

I am still quite amateurish and really need the help!

Thanks in advance.

Provided your query executes successfully, you can access the columns within the users relation from the properties of the $fetch_users_data object. For example, if you have a column called ‘id’, you could fetch the result like so:


$fetch_users_data = mysql_fetch_object(mysql_query("SELECT * FROM `users` WHERE `username`='".$user_data."'"));
$id = $fetch_users_data-&gt;id;

See the PHP manual for more information.

I’d also suggest you to switch over to the MySQLi API for a richer user interface and for peace of mind that the code you’re writing will work in future versions of PHP.