Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

MySQL & PHP SelectBox | 3-part question

Posted on 2004-09-06
6
Medium Priority
?
365 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
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.
0
 

Author Comment

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

anyone?

muchos gracias!!
0
 

Accepted Solution

by:
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.
0
 
LVL 15

Assisted Solution

by:joeposter649
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
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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Dramatic changes are revolutionizing how we build and use technology. Every company is automating, digitizing, and modernizing operations. We need a better, more connected way to work together as teams so we can harness the insights from our system…
When it comes to security, close monitoring is a must. According to WhiteHat Security annual report, a substantial number of all web applications are vulnerable always. Monitis offers a new product - fully-featured Website security monitoring and pr…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
Suggested Courses

927 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