Click to See Complete Forum and Search --> : insert into two or more tables


*TeKKeD*
03-30-2005, 03:40 AM
Can i insert into more than one table within one insert query using PHP and mySQL??

example: mysql_query("INSERT INTO $db_table ( `event_id` , `event_day` , `event_month` , `event_year` , `event_time` , `title` , `description` , `type_event` ) VALUES ('', '$_POST[day]', '$_POST[month]', '$_POST[year]', '$_POST[hour]:$_POST[minute]', '$_POST[title]', '$_POST[description]' , '$_POST[type_event]')");

of course: $db_table = $TBL_PR = "events";
and $TBL_PR = "events";

but if i change $TBL_PR = "events"; to $TBL_PR = "events, second_table, third_table, forth_table";

Can this work, or would i have to make seperate Insert into query's for every other table i want to insert data into and retrive from???

thanks :)

*TeKKeD*
03-30-2005, 06:54 AM
anyone ????

I need to be able to insert more fields into a database and have it display all the correct fields. I'm using this calendar script: http://www.scoznet.com/hyabusa/

Can anyone help me out!!!

ShrineDesigns
03-30-2005, 12:42 PM
they have to be done as seperate queries

Stephen Philbin
03-30-2005, 02:08 PM
You can perform all the seperate queries as one atomic transaction if it is necessary for all the queries to be executed simultaneously and that they must all be sucessful or all fail (as opposed to having some work and some fail which could cause havok in most systems).

To use transactions though, your database tables must use the InnoDB engine. They will not work with the MyISAM (or ISAM) engine tables;

*TeKKeD*
03-31-2005, 03:30 AM
I'm really stuck can someone atleast give me an example on how to do this with the app in the download link?