Re: ID value

From: Date: Wed, 31 Jan 2001 15:55:33 +0000
Subject: Re: ID value
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-37493@lists.php.net to get a copy of this message
> $sql = "INSERT INTO songs (id,name,url) VALUES > ('','Foobar','test.php?id=<id>)"; > > The id is autoincrement so obviously left blank, yet I'd like to put it into > the url where <id> is. > > How do I go about dragging back the id even though it is being created (I > suppose) while the statement is being made -- is it possible or do I have to Try this: mysql_db_query(" INSERT INTO songs (id,name,url) VALUE ('','Foobar','') "; mysql_db_query($sql); $id=mysql_insert_id($link); mysql_db_query=(" UPDATE songs SET (url='test.php?id=$id') WHERE id=$id "; This should work but notice that you have to do 2 SQL queries and this could slow down executing your script if there is some loop. -- Piotr Duszynski http://www.softomat.com.pl http://filmomat.3miasto.pl http://www.3miasto.pl

« previous php.general (#37493) next »