MySQL & PHP SelectBox | 3-part question

Posted on 2004-09-06
Medium Priority
Last Modified: 2008-03-06
I have what I think is a three-part question regarding the creation of a PHP-based computer system configurator:

I currently have 12 HTML/javascript-based computer configurator pages that I developed several years ago, but have recently switched our site over to PHP. I have learned a bit of PHP during the conversion, but am not a serious PHP developer. Problem: I must quickly build a database-driven configurator in order to make site updates less of a monumental chore. The good news? -The site and database are already built, connected and running fine...the only thing I need is the way to pull data into the configurator and have the items auto-total. The bad news? -I want to use the least amount of different HTML templates for the many different types of machine profiles we sell. Optimally, one template should be used with the page data and images altering based on the type/profile chosen by the user.

For the most part, the HTML template for the configurator is already built (it's currently up and running fine using the JS+HTML method), but I REALLY need to find/learn a way to create PHP drop-down select boxes populated from an existing MySQL database (I would love to get away from having to adjust 12 different javascripts each time I want to change some component prices....it's driving me to drink...and not in a good way  8-/  
-These select boxes have to populate based on the processing platform (AMD or Intel) and the profile-type (gaming, professional, server, etc.). The page must also have an auto-updating price total that reflects the sum of all the user-selected choices.

Here is the question(s):

1). What would be a good code example of how to best create the pages based on machine type? Should I use URL query strings on preceding pages to designate how the configurator pages are built?
2). Does anyone have a script that can show me how to pull data into a PHP selectbox? I have a basic understanding, but want to do it right the first time.
3). How on earth can I get the PHP selections to auto-total after a user makes a selection? Is this something I'll still have to incorporate javascript in the pages to do or is there a PHP function that can do it for me?

If you need more specific info in order to present a defined answer, please ask.

-A metric ton of thanks for your suggestions.



Question by:J_D_H
  • 2

Expert Comment

ID: 11994313
1. You can do so by passing the URL strings across the pages. If you want better, you may use either session or cookies to store the configuration values.

2. If you use Macromedia Dreamweaver, you can pull the data into php select box by using DataRecordSet. Or you define all the values in database as array and then print out in the select box by using php echo.

3. You can use simple PHP calculation to calculate the total prices. You just have to define all the fields used in the configurator as PHP constants . Then you have to plus total together and output the prices on the next page.

Hope this will help you, let me know if you have any problem.

Author Comment

ID: 11994471
Hey, thanks mxave, 'preciatecha. But, I hate to sound like a complete newb...but hey, when it comes to PHP, I kinda am. -I'm really not trying to be lazy, I'm just confused. Could anyone post some specific scripts for any of this? The most helpful one at this time would be the select box array logic and db query script...I think that is the most complex part of this issue.


muchos gracias!!

Accepted Solution

mxave earned 500 total points
ID: 11994729
You should browse through the php.net manual and search for array.
Below are the links where you can learn more about PHP Array Logic and DB Query

- http://perl.about.com/library/weekly/aa042103a.htm
- http://www.desilva.biz/arrays/poparray.html (Creating array from DB)
- http://www.tizag.com/phpT/arrays.php

I know one nice commercial script at http://www.esvon.com/pg/products/p_config/ which does everything you need.
LVL 15

Assisted Solution

joeposter649 earned 500 total points
ID: 11997834
<<I currently have 12 HTML/javascript>>
What server side language?  Just change the form actions to your new php pages.

1). I'd pass the info in URL's to allow the user to bookmark any configuration.
2). http://webmonkey.wired.com/webmonkey/programming/php/tutorials/tutorial4.html
3). If you do it in js then you want to make sure you re-do on the server side so people don't create their own form and submit them with their own prices.

Featured Post

Easily Design & Build Your Next Website

Squarespace’s all-in-one platform gives you everything you need to express yourself creatively online, whether it is with a domain, website, or online store. Get started with your free trial today, and when ready, take 10% off your first purchase with offer code 'EXPERTS'.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Magento is the best technology for eCommerce start-ups as it offers the technical expertise and visual appeal to create a store that pulls sales and earns high ROI (Return on investment).
Now many of you may wonder how you can reach great design with least number of essentials. Isn’t stuffing ‘more and more number of elements that speak for the purpose’ the right way to do it? Erm, not always, and in this write-up, you will see why.
This tutorial walks through the best practices in adding a local business to Google Maps including how to properly search for duplicates, marker placement, and inputing business details. Login to your Google Account, then search for "Google Mapmaker…
The viewer will learn how to count occurrences of each item in an array.

590 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question