I am using DHTMLX javascript library to present a grid in a form. My users could have hundreds of products in their grid but I am only capturing the the rows they add a price to. I then need to add those rows to a MySQL database along with some other information.
Getting standard $POST information and manipulating it in my PHP scripts is about the limit of my skills so far so where I need help is the array created by the updated rows. An example of what is being captured in my $POST is:
Array
(
[product] => 64
[dept] => 000
[submit] => Submit
[gridbox_1_4] => 422
[gridbox_64_4] => 534
[gridbox_175_4] => 1234
[gridbox_180_4] => 645
)
I currently capture the basic $POST variables with:
$itemcat = filter($_POST['product']);
$dept7 = filter($_POST['dept']);
My question is how do I capture the gridbox variables so I can use them in an INSERT statement? The only number that will change is the middle number which represents a primary key in my database for the products I need to INSERT into another table. I am assuming I need to explode the $POST variable somehow maybe? Then how do I INSERT them using something like:
"INSERT INTO submissions
(product_id, user_id,submission_id, sugg_price)
VALUES ('" . $gridbox_id . "','" . $myid . "','NULL', '" . $sugg . "')";
All of my reading today on arrays has given me a good understanding of how they work from a 100ft view but not how to specifically solve my problem or even how to start. I’m hoping the community can send me down the right path.
You can loop over the
$_POSTarray and perform a regular expression match on each key: