I want to insert data from a html form into 4 tables in a mysql database using php;
How do I go about it, can it be done with one insert statement?
I want to insert data from a html form into 4 tables in a mysql database using php;
How do I go about it, can it be done with one insert statement?
|--- www.RealJamaicaEstate.com ™ ---|
Invest small = small returns [micro enterprise] | Invest Big = returns Big [macro enterprise]
--- www.fashionsJAMAICA.com ™ -|- www.ChampsJamaica.com ™
nope cannot be done with one insert statement. best you use a stored procedure.
direct me to a tuturial or give me an example because I am kind of new to multiple insert. I only know to insert in one table, but now I have 4 tables and I am stuck;
I am working with dreamweaver 8. This is what I have:
PHP Code:
$query= INSERT INTO table1 (col1,col2,..) VALUES ("value1","value2",..);
INSERT INTO table2 (col1,col2,..) VALUES ("value1","value2",..);
INSERT INTO table3 (col1,col2,..) VALUES ("value1","value2",..);
INSERT INTO table4 (col1,col2,..) VALUES ("value1","value2",..);
mysql_query($query)or die(mysql_error());
Last edited by Utech22; Aug 1, 2007 at 10:44 AM. Reason: dreamweaver
|--- www.RealJamaicaEstate.com ™ ---|
Invest small = small returns [micro enterprise] | Invest Big = returns Big [macro enterprise]
--- www.fashionsJAMAICA.com ™ -|- www.ChampsJamaica.com ™
Here is a tutorial : http://www.w3schools.com/php/default.asp
I checked here already :http://www.w3schools.com/php/php_mysql_insert.asp
I did not find the solution;
|--- www.RealJamaicaEstate.com ™ ---|
Invest small = small returns [micro enterprise] | Invest Big = returns Big [macro enterprise]
--- www.fashionsJAMAICA.com ™ -|- www.ChampsJamaica.com ™
INSERT ALL INTO table1 (name,salary)
VALUES('Julie','22500')
INTO table2 (name,salary)
VALUES('Julie','22500')
INTO table3 (name,salary)
VALUES('Julie','22500')
INTO table4 (name,salary)
VALUES('Julie','22500');
for more info check this out: http://www.tizag.com/sqlTutorial/sqlinsert.php
Last edited by ToxXxic; Aug 1, 2007 at 03:32 PM.
not working for me:
This is what I have before I revise it:
I'll still not getting itPHP Code:
$query = INSERT INTO name (fname,lname,..) VALUES ("Mary","Blige",..);
$query1 = INSERT INTO address (town,parish,..) VALUES ("Mona","St. Andrew",..);
$query2 = INSERT INTO phone (cell,fax,..) VALUES (8760001234,8769230002,..);
$query3 = INSERT INTO computer (brand,type,..) VALUES ("Dell","Laptop",..);
mysql_query($query)or die(mysql_error());
mysql_query($query1)or die(mysql_error());
mysql_query($query2)or die(mysql_error());
mysql_query($query3)or die(mysql_error());
|--- www.RealJamaicaEstate.com ™ ---|
Invest small = small returns [micro enterprise] | Invest Big = returns Big [macro enterprise]
--- www.fashionsJAMAICA.com ™ -|- www.ChampsJamaica.com ™
|--- www.RealJamaicaEstate.com ™ ---|
Invest small = small returns [micro enterprise] | Invest Big = returns Big [macro enterprise]
--- www.fashionsJAMAICA.com ™ -|- www.ChampsJamaica.com ™
You say it is not working for you, but what errors do you get? Also I noticed you are using integers for phone numbers. You should think of using a type of VARCHAR for that information as a user can enter a number like '876-555-1000' which would fail in insert into an integer column.