Re: Hi, simple question

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

or u can just try "select last_insert_id() from test" - thats what i do.
however even mentioning the table-name doesn't seem to be necessary; i just
do it for readability.

-shiva

"Patrik Fomin" <pafo@pafo.net> wrote in message
20030701235235.63166.qmail@pb1.pair.com">news:20030701235235.63166.qmail@pb1.pair.com...
> 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
>
>



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux