[thelist] CF Message Board

Jay jgerland at wnymusic.com
Fri Apr 27 10:06:01 CDT 2001


I'm not sure what type of database you are using but I just encountered
the same thing using MySQL.

After your first INSERT, which creates the auto-incremented id, you can do
something like:

  $subject_id = mysql_insert_id($link);

mysql_insert_id gets the id created from the last insert on the same
connection ($link would be something like: $link =
mysql_connect("sql.server.com","username","password") )

Then you can immediately do another INSERT for the message, with this in
the call:

  subject_id = $subject_id

This was done initially in PHP, but if your using SQL, the premise is the
same.

Hope that helps,

Jay

You Wrote:
> Basically i'd like the user to be able to enter a new subject name and
> an accompanying message on the one form. I've designed the database to
> have a table for subject and for messages. messages will be linked to
> subject. problem is, how do i create a new entry in the subject table
> AND put the new subject id into the message table for the link?






More information about the thelist mailing list