Save cart information, order it and then take it out?

the road is dead!

assume that I am now in the store
I would like to save my current property information
and then press the button to use it. Give it to mysql
but I have a problem
how can I propose to save it?
I now have two must

<input type="hidden" name="cart_prod_id[]" value="<?=$row["prod_id"];?>">
<input type="hidden" name="cart_quantity[]" value="<?=$row["quan"];?>">

one is the quantity, the other is the commodity ID
but how can I receive it at the other end?
this is where my receiver writes

$_SESSION["cart_prod_id"] = $cart_prod_id;
print_r($_SESSION["cart_prod_id"]);

he is printing out

Array ( [0] => 11 [1] => 5 )

but it doesn"t seem to be what I want?
I may need to know which product ID, quantity, and unit
should be saved in what format? Json? How to implement
?

the other one I wrote doesn"t seem to be what I want?

$_SESSION["cart"] = array("prod-id" => $cart_prod_id , "quan" => $cart_quantity);
    echo json_encode($_SESSION["cart"]);
    
    // {"prod-id":["11","5"],"quan":["3","3"]}

what kind of child do you usually have to grow up to be?


there are two numbers 11 and 2323.
generally speaking, as long as the backend can understand it

{
    "11": 2,
    "2323": 100
}

is fine

[{
    "pid": "11",
    "number": 2
},{
    "pid": "2323",
    "number": 100
}]

even this is fine

[[112][2323 100]]

the agreement is self-made. As long as the agreement is made, the data format is not a big problem.
as for how to implement it, Google will do it

.
Menu