E-COMMERCE ON MY SITE.. A LITTLE HELP? I HAVE A COUPLE QUESITONS.?

Question by Nicholas Clark:
E-Commerce on my site.. A tiny help? I have a couple quesitons.?
I created a very basic table in my MySQL database, a product page that varies content by the product clicked on, a cart page, many admin edit/delete/add pages, and have the pages scripted in PHP.
What I am having a few issues with, at this time, is understanding how to have the price dynamic.
By this, I mean having the price change based on a size drop-down menu, when you add it to your cart.
On top of this, I would like to know how to differentiate my products in the cart by size AND color.
On the original, I simply had no options. When you added it to the cart, it checked to…
A. see if the cart was empty
I. If it was empty
a. Add the first item
II. If it was not empty
b. Check to see if that particular item was in the cart, already
A. If the item was in the cart, already, add one more to the quantity in it.
B. If the item was not in the cart, already, then add it as a new item.
I need to include a quantity option to change on the product.php page, as well as color and size options. The color should be sent with the rest of the information so that I might send out the correct item(s). The size (sq. footage) should change the price, which should then by multiplied by the quantity.
If the size AND color were not the same as something in the shopping cart, then it should be added as a separate item. If they are the same, the quantity should be added to the quantity in the cart.
I’m starting to lose focus, and, with it, my mind.
All help appreciated.
If you would like to see my scripts, as basic as they are, just ask. I will save them to a script-storing site and link you to it.
——————————————
Answer by Chris B
When is doubt, use arrays! Well, that is what i say. (oh boy, now i rhyme.)
Arrays can store massive amounts of data in relatively small spaces. In this case, a database table table.
Inside the table, you can simply add a column called “size”, and place available sizes separated by semi-colons (which later you an explode to create a populated array).
IE:
Name – startAmt – size
Rug – 9.99 – 4×4-9.99;5×5-12.99;6×6-17.99
Now here, all you have to do is explode by semi-colon to separate by size with price, then explode that array (using foreach) with dash to separate the size with amount. a print_r (as in my head) would appear as:
Array (
[0] => Array ( [0] =>4×4, [1] => 9.99 )
[1] => Array ( [0] =>5×5, [1] => 12.99 )
[2] => Array ( [0] =>6×6, [1] => 17.99 )
)
Hope this gives you a spark of thought as to what you can do with an array. NOTE: color can work similarly.
This array method might not be the most efficient – but it is the least work required.
Hope this helps (even a little!)
If you need further assistance/advice, feel free to contact me.
——————————————
Know better? Leave your own answer in the comments!









about 1 year ago
$.001
about 1 year ago
How you can start earning money with Adsense can be done easily and quickly. You will be amazed at the results you will be getting in such a short period of time.
Start by writing some quality content articles which are also keyword incorporated. There are a lot of people given the gift of being good with words. Writing comes easy for them. Why not make it work in such a way that you will be earning some extra cash in the process.
There are actually three steps to put into mind before you begin writing your ads and having an effective Adsense.
Keyword search. Find some popular subjects, keywords or phrase. Select the ones which you think has more people clicking through. This is actually a keyword selector and suggestion tool that some sites are offering to those who are just their Adsense business.
Writing articles. Start writing original content with keywords from the topics that you have achieved in your search. Take note that search engines are taking pride in the quality of their articles and what you will be writing should keep up with their demands.
Quality content site. Build a quality content site incorporated with Adsense ads that is targeting the subject and keywords of your articles and websites. This is where all that you’ve done initially will go to and this is also where they will prove their worth to you.
about 1 year ago
You won’t get much, its better to get viewers that will actually click, which you can do with the monster answer I just posted:
http://answers.yahoo.com/question/index;_ylt=Ar.NXczEuB3f53GojfdfvjFt.Bd.;_ylv=3?qid=20090505224532AAWzgN4