On Monday 16 December 2002 01:22, drparker wrote:
This is the type of question that is best asked on the php-db list.
> I'm adding information with the INSERT command to 2 tables. In the
> first table, called "courses", I have a field called "course_id" that is
> an auto-increment - assigned by the table. In the second table, called
> "par", I have a field also called "course_id". I need to assign to
> this field the value that is assigned for "course_id" in the "courses"
> table. The problem is, I don't know what it is going to assign, and I
> can't get the variable with a query such as "SELECT * FROM counties
> WHERE course_id = ##" because I don't know what number is going to be
> assigned as the course_id. Basically, I need to store the that
> course_id value of the course I just added in a a variable, and I don't
> know how to retrieve that variable.
If you're using MySQL you can use mysql_insert_id(). If you're using some
other DBMS then have a look at the manual to see whether there is a similar
Jason Wong -> Gremlins Associates -> www.gremlins.biz
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *
Pardo's First Postulate:
Anything good in life is either illegal, immoral, or fattening.
Everything else causes cancer in rats.
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php