Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

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

Guest
Dec 20, 2007 Dec 20, 2007
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...
TOPICS
Server side applications
704
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Dec 21, 2007 Dec 21, 2007
So you want to run a query and then copy all results into another table?
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Dec 21, 2007 Dec 21, 2007
yes....any idea???
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Dec 21, 2007 Dec 21, 2007
LATEST
"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)



Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines