i’m sending values from one page via jquery’s ajax to a php page. I’m hoping to store the recieved values into a db. so far this is my php page:
<?php
$supp_short_code = $_POST['supp_short_code'];
$om_part_no = $_POST['om_part_no'];
$description = $_POST['description'];
$price_each_nett = $_POST['price_each_nett'];
$cost_total = $_POST['cost_total'];
?>
The thing is, this php is going be receiving potentially multiples of each post with every “submit” so there could be 5 of each (ie. 5 items ordered). So where would i go from here to stick these values into a suitable mysql query. Also every order needs to have a unique id. Its actually getting the same id number to each order item that i’m struggling with, if that makes sense? Do these need to go into an array and then through a for-loop? Essentially one row in the db is these fields from the “post”…
The form fields need to be element arrays in HTML, and you will have to treat each $_POST element as an array. In your form’s HTML add brackets to the field names, i.e. name=”supp_short_code[]” When the form is submitted you can loop through these items and complete an insertion into the database.