I've got two tables, one with some data and a user_id field, the other with a password field and user_id field. The user_id in table 1 is on auto_increment. The data and password come from a form. I insert the data into the 1st table with something like,
insert into table1 (user_id, var1, var2,...) values (null, $var1, $var2,...);
Now I've got to extract the value of user_id from table 1 so that I can insert the user's password along with the right user_id.
Can I use MAX(user_id)? Will that always return the last auto_incremented value of user_id?
I'm assuming that any two rows may be identical except for user_id, so I can't use a comparison of field values to extract a particular user_id value.
[edit]
p.s. how do I get the value of MAX() in php? I've got,
// get the unique vendor ref number, and save it.
$sql="select MAX(vend_id) from vendor";
$result=mysql_query($sql) OR DIE (mysql_error());
echo ("Num records = ".$result."<br>");
I get $result=resource id#3
How can I get $result=3?
[/edit]