Reputation: 113
I need to know the current user_id
where this user_id
is an auto increment column.
How to find the current user_id using php code?
Suppose, the last user_id
is 23.
The next created user will have an user_id of 24. How to know this after executing the related INSERT
query?
Upvotes: 1
Views: 61
Reputation: 160
To get the last added user id, where id is auto-increment:
$n = mysql_query("SELECT max(id) FROM tablename");
Thus, the return value of mysql_query
gives it back to you. In your example, $n
will be 24.
Upvotes: 1