Solved

MySQL & PHP SelectBox | 3-part question

Posted on 2004-09-06
6
343 Views
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.

cheers,

JDH

0
Comment
Question by:J_D_H
  • 2
6 Comments
 

Expert Comment

by:mxave
Comment Utility
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.
0
 

Author Comment

by:J_D_H
Comment Utility
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.

anyone?

muchos gracias!!
0
 

Accepted Solution

by:
mxave earned 125 total points
Comment Utility
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.
0
 
LVL 15

Assisted Solution

by:joeposter649
joeposter649 earned 125 total points
Comment Utility
<<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
http://www.w3schools.com/php/php_db_odbc.asp
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.
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Read about why website design really matters in today's demanding market.
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo‚Ķ
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

762 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

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now