Re: Add data to three tables at once from one form
| From: | Julian Wood | Date: | Thu, 19 Apr 2001 21:33:05 +0000 |
| Subject: | Re: Add data to three tables at once from one form | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-49429@lists.php.net to get a copy of this message | ||
> That's it. There's nothing special to do.
Except if one insert fails and the others succeed, you run into a bit of
sync trouble. This is what transactions are for. You might want to consider
a BDB table type, which supports transactions, then you have the option to
rollback the other inserts if one of them fails.
Julian
on 4/18/01 6:33 PM, Steve Werby at steve-lists@befriend.com wrote:
>
> "Fates" <fates@home.com> wrote:
>> I know how to add data to one table but how do I add data to three
>> tables from one form?
>>
>> I want to do this with just one form and on one web page so it doesn't
>> post to another page.
>>
>> How do I set up the insert statement?
>>
>> $query = "INSERT INTO $table VALUES ('$menu_id', '$server',
>> '$menunumber', '$menuname')";
>>
>> $result = mysql_db_query($dbname, $query);
>
> Add two more sets of statements like those you have for the first query.
> That's it. There's nothing special to do.
>
> --
> Steve Werby
> President, Befriend Internet Services LLC
> http://www.befriend.com/
>