0

I have create multiple row by using javascript. Now how to save these row in mysql. I already using some type of code, its not working. here my code is [http://jsfiddle.net/bb2pJ/] and php code for adding these value.

`

include "config.php";

if(isset($_POST['submit']))
{

 foreach ($_POST['code1'] as $key => $value) 
    {
        $code1 = $_POST["code1"][$key];
        $product1 = $_POST["product_name1"][$key];
        $qty = $_POST["quantity1"][$key];
        $rate = $_POST["amount_name1"][$key];
        $total = $_POST["total_name1"][$key];


        $sql = mysql_query("insert into      testing(code,product,qty,rate,total)values('$code1','$product1','$qty1','$rate1','$total1')")or die(mysql_error());        
    }

}   
?>`

1 Answers1

0

From you Js fiddle code, you are trying to post array of values for each field (ie code, proddname, ...).

How are submitting these values? If not passing through ajax post, then you need to declare fields names like code[], product_name[] ... as array for all fields so they will be submitted as array.

Rest code you have writtten above should work by using proper field name like code for code[] ... .

Please put proper spacing between your keywords and values/fieldname in your insert into.. statement.

RajeshK
  • 459
  • 5
  • 10