buffiron Posted February 19, 2007 Share Posted February 19, 2007 Hi, I’m a PHP newbie. I’m trying to code the scenario below for a coding exercise. I have setup the table for my sample merchandise but I dont know where to start on the script. Please help. Thank you! Scenario: 1. Online shopper must select 10 items from a drop down merchandise list with total amount of less than or equal $100. Shopper cannot select the same item. All items must be unique. 2. Shopper will have the option to select another 10 items as a replacement list. Shopper cannot select the same item. All items must be unique. 3. Shopper will be charged $1 if she wants to replace an item in her shopping cart from her replacement list. 4. Shopper will be charged $3 if she wants to replace an item in her shopping cart that is not available from her replacement list. Link to comment https://forums.phpfreaks.com/topic/39171-need-help-w-a-shopping-scenario-exercise/ Share on other sites More sharing options...
boo_lolly Posted February 19, 2007 Share Posted February 19, 2007 this seems like a steep exersize for a noobie. it also seems like half of your excersize could be done in javascript (client-side) instead of having php as a server-side confirmation. anyway, you could do this several ways. but i'd have 2 forms. the first form and the second form would pretty much be exactly the same. have a list of items that the user can choose from. these will be displayed in the form of a checkbox. this way, the user cannot select the same item twice. then submit to the second form which is exactly the same as the first, except this is their replacement item list. then, submit to a form that asks them if they want to replace anything, and yadda yadda yadda, let us know if you have trouble getting this far. Link to comment https://forums.phpfreaks.com/topic/39171-need-help-w-a-shopping-scenario-exercise/#findComment-188702 Share on other sites More sharing options...
buffiron Posted February 19, 2007 Author Share Posted February 19, 2007 Thanks Lolly! Yes, its too complicated for a newbie. Hey, I have to graduate from outputting "Hello World" in PHP! LOL I'll also try to solve this exercise using java. The problem with the check box is if there are more than 100 items to choose from. Link to comment https://forums.phpfreaks.com/topic/39171-need-help-w-a-shopping-scenario-exercise/#findComment-188799 Share on other sites More sharing options...
boo_lolly Posted February 19, 2007 Share Posted February 19, 2007 more than 100 items is no problem. if these items are coming from a database, you can use php to connect to the database, and print out all the items with checkboxes using just a few lines of code. or, if these items are created manually, you could put the items in an array, and then use a foreach loop to populate the list of items with checkboxes. again, just a few lines of code. let me know where the items are coming from, and i'll help you from there. Link to comment https://forums.phpfreaks.com/topic/39171-need-help-w-a-shopping-scenario-exercise/#findComment-188873 Share on other sites More sharing options...
buffiron Posted February 19, 2007 Author Share Posted February 19, 2007 The items list will be pre-built in mySQL table and this exercise calls for 350 items. Can I put the list directly on an HTML page? I already have an idea how to tackle this problem using 3 forms but my problem is how to write all the script but I've completed the shoppers registration and authentication process. 1st form or Shopping Form, For straight shopping scenario: I'm thinking of having 10 dropdown menu list (1st dropdown menu for 1st item bought and so on) for the bought items and another 10 dropdown menu list for replacement items. Each drop down menu list wll contain all the 350 mechandise but should stop or alert the shopper if she selected the same item. Also, a running balance or total should be visible to alert the shopper if she has exceeded the required maximum spending limit of $100. 2nd form for Exchange or Return form from Replacement list: The shopper will have the option to exchange the original items she bought from the replacement list she made in the 1st form. I think check box can be employ here since we can just simply switch the bought items in the shopping cart with the replacement items. Shopper will be charged $1 for each replacement she made and must still mainain a $100 spending limit while replacing an item. 3rd form for Returning items and buying new items: Shopper will also have the option to return items and buy new ones from the inventory (350 items). Like in the first form, I'm thinking of using 20 drop down menus to select a new item. Shopper will be charged $3 for each replacement she made and must still mainain a $100 spending limit while replacing an item. Link to comment https://forums.phpfreaks.com/topic/39171-need-help-w-a-shopping-scenario-exercise/#findComment-188932 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.