Re: writing to 2 tables
| From: | David Robley | Date: | Mon, 19 Jul 2004 09:07:39 +0000 |
| Subject: | Re: writing to 2 tables | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-35363@lists.php.net to get a copy of this message | ||
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.