Re: Hi, simple question
| From: | Oscar Rylin | Date: | Wed, 02 Jul 2003 00:02:17 +0000 |
| Subject: | Re: Hi, simple question | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-29010@lists.php.net to get a copy of this message | ||
see mysql_insert_id($link_identifier)
-- rylin
Patrik Fomin wrote:
Hi, im adding a post to the database, is there any way to retrive back the ID for the post that i just created? the id is auto_increment and primary key. like $sql = "insert into test (namn, www) values('test', 'test.com')"; mysql_query($sql); $row = mysql_get_post("id"); ? the only way i could think of was to create a tempfield in the database and each time you post you give the temp field a unique value, like: $sql = "insert into test (namn, www, unique) values('test', 'test.com','25323324')"; mysql_query($sql); $sql = "select id from test where unique = '25323324'"; $res = mysql_query($sql); regards patrick