ok what i did was this now. you click on "add to cart" this brings up the little add to cart screen.
this has the following code:
session_start();
if ($number_of_items) {
if (count($product_name) == 0) {
$product_name = array();
}
if (count($quantity) == 0) {
$quantity = array();
}
if (count($id_product) == 0) {
$id_product = array();
}
if (!session_is_registered("product_name")) {
session_register("product_name");
}
if (!session_is_registered("quantity")) {
session_register("quantity");
}
if (!session_is_registered("id_product")) {
session_register("id_product");
}
array_push($product_name,$product);
array_push($quantity,$number_of_items);
array_push($id_product,$id);
so this is where most of the stuff happens,first i check if the arrays are null [so that you create arrays if there arent any - and not delete ones that allready exist] , then register the arrays as sessions. next i push the new values into the arrays.
the only thing that confuses me is how do i put these 3-4 arrays together?
so now on my main page i have:
session_start();
$number_rows = count($product_name);
if ($number_rows > 0) {
foreach ($product_name as $value) {
$writearray .= "<b>Product:</b> ". $value. "<br>";
}
foreach ($quantity as $value2) {
$writearray .= "<b>Quantity:</b> ". $value2. "<br>";
}
foreach ($id_product as $value3) {
$writearray .= "<b>id:</b> ". $value3. "<br>";
}
}
the reason i am using 3 seperate arrays is bacause i dont need to use multidimensional arrays as a product doesnt have arrays inside them - only product name, price, description, id etc.
but how can i create the 3 arrays here now into one array that i can output on my form?
could i use array_merge($product_name,$id_product) - but that wouldnt work as it would just throw it all together?