2

I am trying to create small shopping cart without sql database. My products are in directory and getting the files with foreach script, wich is working..

how can I set variables to var1, var2 var3 and so on, with each products

should i use if var1 isset in each product1.php files. and now when I think it would be best if the varX is set by the filename of the each product, as the product1.php can be someproduct.php also.( the X would be the filename)

the someproduct1.php someelseproduxt.php is listed below each other on the page

and the second question. I would put the "add to cart" link to every product page so the $varX would be reset as $cart_varX and the shopping cart "module" has if isset which checks the if the buyer has added it to the cart. So the question is how can I use <a href=""></a> to use to set variables and return to page where is the link clicked?

but if the variables is filename based the .php would be nice get of, but not necessery

1
  • 2
    are you sure you should be developing a shopping cart ???
    – Baba
    Apr 8, 2012 at 20:03

1 Answer 1

1

First off, all of this sounds really ugly and it seems that you are very unsure about php basics, which leads to the question whether or not you should develop a shopping cart application.

Furthermore, i would strongly recommend you to use some kind of dbms or storage system to perform complex queries for your products later.

However if you want to specify the product details in single php files (which -again- i think is a bad idea) you'll should probably use a shared multidimensional array where every product has its own unique key.

1
  • does that matter? that does not sound ugly. I am not going to make the shopping cart as big as the for example oscommerce or so.. just trying to make it simple and small, and none of the customer data is being stored. Only data will be sent by email, what products customer wants and what is the customer information.
    – Joakim
    Apr 8, 2012 at 20:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.