Re: Hello List,

From: Date: Sat, 01 Jul 2000 22:21:10 +0000
Subject: Re: Hello List,
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-4311@lists.php.net to get a copy of this message
On Sat, 1 Jul 2000, eric wrote: > Hello List, > > I've got a form that inserts related data into 2 different tables . One > of the tables has an auto_increment > pri key. I want to relate the tables based on the primary key, but can't > > see how to determine what the auto_incremented value WILL be in the > first table so that I can submit that value (and consequently join the > tables) into the second table. > > I'm using php and have thought of using mysql_insert_id() + 1, but that > doesn't seem like a good idea. For future reference, your subject contained a solid paragraph of your message. If it wasn an accident, be careful. :) Actually, mysql_insert_id() is what you want, but probably not +1. mysql_insert_id() will inform you what the last incremented value used by an insert was. That is, if you do a query that inserts a row into a table with an auto_incremented value, then mysql_insert_id will return the incremented value that was used. Matt

« previous php.general (#4311) next »