Re: Getting last record ID created from DB

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

 



On Fri, 16 Mar 2007 22:28:54 -0500
"Jeff" <akaman@xxxxxxxxxxx> wrote:

> Is there a way to get the last Record # created by the DB.
> 

> 
> $query = "INSERT INTO `t_users` (`user_id`, `f_name`, `l_name`,
> `e_mail`, `b_date`, `pic`) VALUES ('', '$f_name', '$l_name',
> '$e_mail', '$b_date', '')";
> $result = mysql_query($query);
> if(!$result)
> {
> die("Could not query the database: <br/>".mysql_error());
> }
> echo "Your Player information has been stored OK.<br />";
> 
> what code could I add here to make the following line work?
> 
> echo "REMEMBER your USER ID# you will need it when creating
> Characters!! It is: $user_id"; <----- I want to show the "user_id"
> just created here.
> 
> Thanks in advance! 
> 

select user_id from t_users where user_id = (select max(user_id) from
t_users)

-- 

Rod

-----

Empty your mind, be formless, shapeless like water.
Now you put water into a cup and it becomes the cup.
You put water in a bottle it becomes the bottle.
You put it into a teapot it becomes the teapot.
Now water can flow or it can crash.
Be water, my friend.
 -- Bruce Lee

Attachment: signature.asc
Description: PGP signature


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux