I have a shopping cart type arrangement. The customer builds the order in tiers. So page one is item 1, page 2 item 2....... The page does not reload during the building of a order. (jqtouch) My way of building the order is add each item to an array. Below is how I have created the array.
var item_contents= new Array();
so typical order with two items would look something like..
item_contents[0] = 627
item_contents[1] = 451
item_contents[2] = 365
item_contents[3] = 548
item_contents[4] = 158
item_contents[5] = 154
item_contents[6] = 155
item_contents[7] = 115
The number is the item_id
number in a database. The user has the ability to go back and alter an item in the array for the current order.
When the checkout screen is shown this needs to be submitted and details for the respective item_id
returned. I guess the best way would be someway to replicate the array above in php. How Would I POST
an array like this and get it to look identical in php?
Thx
jquery post
var a = [627,451,365,548,158,115,155,115];
$.post("ajax.php",{data: a},function(data){
console.log(data);
});
php
<?php
$array = json_decode($_POST['data']);
foreach($array as $key => $value){
add(sanitize($value[$key]));
}
?>