I’m working on a fairly large project in (object oriented) PHP which includes a webshop where users can buy products and additional licenses and services. Purchasing is a four step process:
- Step 1: User chooses a product, and
product_idis passed to step 2 - Step 2: Fetching and outputting all license types based on
product_id, passingproduct_idon to step 3 - Step 3: Fetching and outputting all services based on
product_id, in a form with checkboxes namedservices[$service_id]
So now, on the checkout on step 4, I fetch the correct products and licenses from the database, but I also have to get the correct services from the db based on the services array, and calculate the price to output. At last, I’ll have to assign the services array to the Smarty template.
How would the most suitable way to do this be? I really hope that someone is kind enough to help me out here, as I’m having a very hard time trying to make this work.
Thank you so much in advance.
Try using
$resulter = array(); $i = 0; foreach($product_id as $value) { $query = "Select FROM products WHERE product_id = $value";Your execution code $resulter[$i] = $result; //$result could be a assoc array $i++ }
And If I ware you I would i would use a multidimensional array like I shown above.