MySQL & PHP SelectBox | 3-part question

Posted on 2004-09-06
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'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
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 125 total points
ID: 11994729
You should browse through the manual and search for array.
Below are the links where you can learn more about PHP Array Logic and DB Query

- (Creating array from DB)

I know one nice commercial script at which does everything you need.
LVL 15

Assisted Solution

joeposter649 earned 125 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.
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Any business that wants to seriously grow needs to keep the needs and desires of an international audience of their websites in mind. Making a website friendly to international users isn’t prohibitively expensive and can provide an incredible return…
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
The viewer will learn how to count occurrences of each item in an array.
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

726 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