Re: writing to 2 tables

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

 



On Mon, 19 Jul 2004 18:33, Phpdiscuss - Php Newsgroups And Mailing Lists
wrote:

> Hi all,
> 
> I am writing a PHP newsletter where users are able to write the news and
> for the information to be written to 2 tables in the database. I can do
> this for one table but it need it for 2.
> 
> Obviously what needs to happen if that the two ids from t1 and t2 be
> linked together but how do i get the code to tell it to write to both
> tables using the same id??
> 
> Does anyone know how this would be done?
> 
> All comments appreciated!
> =)

If your table t1 has an autoincrement field, insert to that table, use
mysql_insert_id to get the id from that insert and use it in your insert to
t2.

-- 
David Robley

"There it is again!" Tom recited.

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux