I don't know what i'm doing wrong here.
When I get to the last page and make an
print_r($_SESSION['products']);
this is the result
Array
(
[37] => 5
[38] => 5
[39] =>
[40] =>
[41] =>
[42] =>
[43] =>
[44] =>
[45] =>
[46] =>
[47] =>
[48] =>
)
Only the lasts entrys of the array are listed. I'm using session_start(); in all pages so the session should be continued and the $_SESSION['products'] array should have all the items that have been added in earlier pages.
About your second example I understand it but could you explain it english what it does?
I have other tables but the main part is like this:
two important tables:
store_products
id
cat_id > id from category table
product_name
product_price
product_description
product_active > For activate or deactive a product whitout delete the entry.
store_shopper_track
id
session_id
sel_product_id
sel_product_cant
date_added
In every page I'm inserting the sel(selected) products and its qty to this table along with the session_id and the date.
But I'm seeing that in your second example the query expect the prices too, to make the calc.
Here is my question:
What do you think is the best method to use:
Pass all the data in the $_SESSION['products'] array, make a query and do the calc.?
or
When the user press the submit to go to the next page insert the selections in the table shopper_track along with the session_id and then in the last page query for all the items selected for the matching session_id?
I was using the second method but a little problem was anoying me when I do a back in the browser and change a qty. I was getting duplicates items in the shopper_track table, what method could I use to overwrite the seleccions in case of the user wants to make changes to the selections?.