hi
When I insert a record into mysql, it assigns it an auto number for the ID, how can I found out what number it is assigning the record I am inputting?
thanks
i believe the SQL function is LAST_RECORD_INSERTED() then just increment this number by 1
ok I found the function... tried to use it but can't get it to work, this is what I have
$number = mysql_query("LAST_INSERT_ID();")
no value is in $number when I run it
I'm getting closer!!
Now I got as my code
$number = mysql_query("SELECT LAST_INSERT_ID();"); echo $number . "YA";
and it prints this Resource id #3
but that is not the record number.
may require a table name.... 😉
ok tried that but got the same message the code was mysql_query("SELECT LAST_INSERT_ID('tablename');")
this came up. Resource id #3
ahh maybe this will help
https://ific.uv.es/informatica/manuales/MySQL/Manual_chapter/manual_Clients.html#Result_values
apparently it only works after an INSERT.... or so it sounds...
thanks it works when i do this
$number = mysql_insert_id();
np 😉