0

Hello
I want to do that after submitting form it will insert in a table. the table has auto increment field. name of the field is ID. Now how can I get the ID number of that inserted data's ID number. for example

I have a table which field are as bele
1. user_ID as auto increment number
2. user_name as varchar
3. father_name as varchar

No I want that When I submit a form which has user name & father name text box. It will be inserted in the table. After inserting those data It will show me the ID of that user. remember user_name is not uniq. I know how to insert.

Just tell me how can I get the ID. Thank u

3
Contributors
2
Replies
3
Views
6 Years
Discussion Span
Last Post by sops21
0

I've used this before. $id is the the value of the primary key of the row that you just inserted.

$link = mysql_connect(DB_HOST, USER, PASSWORD) or die(mysql_error());
mysql_select_db(DATBASENAME) or die(mysql_error());  

$query = "query here";
mysql_query($query)
$id = mysql_insert_id($link);
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.