[thelist] basic mysql key question.

Edwin Martin e.j.martin at chello.nl
Mon Apr 22 05:43:01 CDT 2002


Hi kris,

>my poor brain is thinking that i have to:
>
>1. insert into table_images
>2. select image_id from table_images where image_name = image_name
>3. update table_story
>
>in three separate database queries - which to me seems like a rather basic
>and inelegant means of doing this.
>
>could someone point me in the right direction?

Use mysql_insert_id() to get the id of the last inserted row.

See:
http://www.php.net/manual/en/function.mysql-insert-id.php

Bye,
Edwin Martin.





More information about the thelist mailing list