OK, here is how I interpreted your question.  When you insert data into a
table, you want to get back it's newly created ID. All you need to do is,
after inserting the field, select back the id of that field where id is the
max(id) created (assuming you are using auto_incrementing ID field.)

For example, you just inserted the new user data:

insert into user (name,login,password,permissions) values ('Jane
Doe','jdoe','jane555', 125);

Now, you want to retrieve the ID of the newly inserted record. If you using
an automatically incrementing ID field, you can recall the ID by doing like
so:

select max(id) as id from user where login='jdoe';

This is not an exact; but considering you probably have a unique constraint
on the login field, there should be only ONE record with the login='jdoe'.

This is one way to do all this. If the data is such that it could exist
multiple times, you can consider other ways to pull back the ID. If you need
more examples, I can provide you with. I've done this many times in my web
apps.

Good Luck,
Nicole Amashta
www.aeontrek.com
==============================

"James Mansfield" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> OK...newbie question it must be:
> I want to add an entry into a db tb (using php obviously) and when its
added
> into the db its gets a sequencially numberred id....now can I retrieve
this
> id numbe rin the same php coded page as what I create the entry with? If
not
> what is the best way around it? Create a unique number for the entry
before
> adding it into db??
>
>



-- 
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to