0
Insert multiple rows into database based on form data entry using PHP & mySQL

/t5/dreamweaver-discussions/insert-multiple-rows-into-database-based-on-form-data-entry-using-php-amp-mysql/td-p/497506
Dec 20, 2007
Dec 20, 2007
Copy link to clipboard
Copied
I have tried to find tutorial about this but still no luck.
Here, i would like to get some help...
i have 1 table that contain a list of property.
Then, make a recordset (rsProperty) and list it using recordset repeat region (Server behaviour > Repeat Region)
How do i loop OR transfer OR copy all the result from rsProperty into 1 hidden form and using INSERT statement
=============
sprintf("INSERT INTO.....
=============
into new table rsProperty2 row by row???
example what i want to do:
rsProperty2
001
002
003
004
==========
Code that i have tried to make:
==========
for ($i=0; $i<$totalRows_rsProperty; $i++) {
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
$insertSQL = sprintf("INSERT INTO multiple_property (property) VALUES (%s)",
GetSQLValueString($_POST['hiddenField'], "int"));
mysql_select_db($database_rental, $rental);
$Result1 = mysql_query($insertSQL, $rental) or die(mysql_error()); }
}
Result from this code:
table.Property
001
001
001
001
==========
The looping work but only get 1 row from repeat region, missing 002,003,004...
What i want is to get all the result, 001,002,003,004
Please somebody help me...
Here, i would like to get some help...
i have 1 table that contain a list of property.
Then, make a recordset (rsProperty) and list it using recordset repeat region (Server behaviour > Repeat Region)
How do i loop OR transfer OR copy all the result from rsProperty into 1 hidden form and using INSERT statement
=============
sprintf("INSERT INTO.....
=============
into new table rsProperty2 row by row???
example what i want to do:
rsProperty2
001
002
003
004
==========
Code that i have tried to make:
==========
for ($i=0; $i<$totalRows_rsProperty; $i++) {
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
$insertSQL = sprintf("INSERT INTO multiple_property (property) VALUES (%s)",
GetSQLValueString($_POST['hiddenField'], "int"));
mysql_select_db($database_rental, $rental);
$Result1 = mysql_query($insertSQL, $rental) or die(mysql_error()); }
}
Result from this code:
table.Property
001
001
001
001
==========
The looping work but only get 1 row from repeat region, missing 002,003,004...
What i want is to get all the result, 001,002,003,004
Please somebody help me...
TOPICS
Server side applications
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
Explorer
,
/t5/dreamweaver-discussions/insert-multiple-rows-into-database-based-on-form-data-entry-using-php-amp-mysql/m-p/497507#M139043
Dec 21, 2007
Dec 21, 2007
Copy link to clipboard
Copied
So you want to run a query and then copy all results into
another table?
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more

Guest
AUTHOR
/t5/dreamweaver-discussions/insert-multiple-rows-into-database-based-on-form-data-entry-using-php-amp-mysql/m-p/497508#M139044
Dec 21, 2007
Dec 21, 2007
Copy link to clipboard
Copied
yes....any idea???
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
LEGEND
,
LATEST
/t5/dreamweaver-discussions/insert-multiple-rows-into-database-based-on-form-data-entry-using-php-amp-mysql/m-p/497509#M139045
Dec 21, 2007
Dec 21, 2007
Copy link to clipboard
Copied
"Kai?" <webforumsuser@macromedia.com> wrote in message
news:fkh410$muj$1@forums.macromedia.com...
> yes....any idea???
Create a form with hidden fields or checkboxes with the primary key for your
table
In the list
See the Insert ... Select syntax
http://dev.mysql.com/doc/refman/5.0/en/insert-select.html
INSERT INTO othertable(field1,field2) SELECT field1,field2 FROM thetable
WHERE id IN (varIds)
news:fkh410$muj$1@forums.macromedia.com...
> yes....any idea???
Create a form with hidden fields or checkboxes with the primary key for your
table
In the list
See the Insert ... Select syntax
http://dev.mysql.com/doc/refman/5.0/en/insert-select.html
INSERT INTO othertable(field1,field2) SELECT field1,field2 FROM thetable
WHERE id IN (varIds)
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more

