PHP-Database help please!

I have some php code and heres parts of it:

$user_name = $_SESSION[‘user_name’];
$varnotes = $_POST[‘formnotes’];
$sql_insert = "INSERT into notestable
(user_name,notes) VALUES (’$user_name’,’$varnotes’) ";

I need a php script that allows me to show the last saved ‘note’ that the specific USER that is signed in has made… i got it to save the note to the database, but im clueless on how to have the LAST SAVED NOTE from THAT USER shown on the page…
SOMEONE PLEASE HELP ME!!

something like this should do it:

[php]
//select all fields from the database where user_name is the same as the one stored in the session order by the id in descending order and limit to 1 so only 1 record will be returned
$query = mysql_query(“SELECT * FROM notestable WHERE
user_name=’”.mysql_real_escape_string($_SESSION[‘user_name’])."’ ORDER BY id DESC LIMIT 1");

//add record to an object
$row = $mysql_fetch_object($query);

//print out the result
echo $row->notes.’ by: '.$row->user_name;
[/php]

Sponsor our Newsletter | Privacy Policy | Terms of Service