Not quite relevant question about coding and query

From: Date: Fri, 19 Jan 2001 19:00:06 +0000
Subject: Not quite relevant question about coding and query
Groups: php.general 
Request: Send a blank email to php-general+get-35569@lists.php.net to get a copy of this message
Hi people Using db as Mysql, I want to write a query to insert data into a table, say User table, and right away after I have inserted that particular record into User table, I want to retrive the ID for that particular record (the record that I just inserted) to insert into another table, say UserRequest, that require to have UserID field in there as well. By the way, I configure the ID field in User table as auto increment, and unique key. Can I just write a query to retrive UserID right after I have inserted user detail into Usertable? and then assign into a variable and use that value to insert into UserID field in another table? like this: $query = "insert into user values ('firstname','lastname','address','phone')"; $resultinsert = mysql_query($query); $getID = "select userID from user"; // Will this get me the Id of the record I just inserted? $resultID = mysql_query($getID); $anotherQuery = "insert into userrequest values('userID','userRequestDetail')"; $resutlrequest = mysql_query($anotherQuery); Will it work if i did that? If not, what should I do to achieve this? cheers Jack jacky@activelifestyle.com "There is nothing more rewarding than reaching the goal you set for yourself"

« previous php.general (#35569) next »