Showing posts with label MySql last inserted row. Show all posts
Showing posts with label MySql last inserted row. Show all posts

Monday, June 16, 2008

How to get the MySql last inserted row using PHP?

When you use a auto increment primary key id field, you usually have no track of what is the current inserted id in the auto increment field. But there are situation where you need to know the last increamented id.
You can simply use mysql_insert_id()



<?php

mysql_query("insert into mytable (v_name) values ('kusal')");
$last_id = mysql_insert_id();

echo $last_id;

?>


Freelance Jobs