Need to create a dynamically populated dropdown box for selling shoes

Posted on 2006-06-22
Last Modified: 2010-04-27
Okay here is what I need.  I'm starting a website selling shoes and on the 'Buy' page, I need a dynamically populated dropdown box.  Let's say I have 10 pairs of size 11, well I need the dropdown box to be smart enough to know that when 10 people purchase size 11, I have run out of size 11 and this option no longer appears in the dropdown box.  Also, I need to be able to link the size the person picks in the dropdown box to the paypal website so that when the person checks out, it specifies what shoe size/type of shoe they have selected.  Thanks.
Question by:AirCarter15bh
  • 2
LVL 21

Expert Comment

by:Julian Matz
ID: 16963760
I can give you some guidance for php/mysql...

$connection = mysql_connect('localhost','username','password') or die ( mysql_error() );

$query = "SELECT * FROM table_shoes ORDER BY size";
$result = mysql_query($query,$connection);

<select name="shoes">
while ( $row = mysql_fetch_assoc($result) ) {
 echo "<option value='{$row['id']}'>{$row['name']} - {$row['color']} - {$row['size']}</option>\n";

When the form is then submitted, you will receive the ID number, so all you have to do is run a database query on that to get the rest of the data to populate input fields for PayPal or whatever....

Hope this helps...

Author Comment

ID: 16965042
I don't really understand what you have given me.  Is this code that I can input into the head of my html? Give me a little guidance here on what this is and how I use it and what it will do for me.  Remember, I'm a newb at this stuff.  Talk to me like I'm highly uneducated about the subject...because I am, thanks.
LVL 21

Accepted Solution

Julian Matz earned 250 total points
ID: 16965144

No problem... The above is a server-side scripting language called PHP and it uses a database management system called MySQL. Both require the server on which your site is on to have the software installed on it. Both are open-source and free, so in most case you'd find the two installed on Linux servers.

The code can be placed anywhere on your HTML page, but must start and end with these two:
 //php code...

and the server must know to parse the code, so you need to give it a .php extension (rather than .html or .htm).

The php connects to a MySQL database (I didn't know what kind of database technology you were using, but I'm thinking you will need some sort of a database to be able to do what you're trying to achieve).

There are many step-by-step php/mysql tutorials on the web... Just type "php mysql tutorial" in Google.
Another great resource os the PHP manual -

PHP and MySQL might not be available to you, in which case I don't think I can be of much help to you...
If you don't know if php is installed you can run a quick test...

Open a page for editing and add the following lines of code:

echo "This is a test...\n";
// You should not be ale to read this line...

Then save it as "test.php" and upload it to your server.
Open the page in your browser by entering the URL to it:
http ://www

If you can only see the text "This is a test..." then php is installed and working...
You should not be able to see the rest of the code or the text which reads "You should not be ale to read this line...".

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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

Read about how to choose the best possible content marketing agency to suit your needs. Content marketing has become an integral part of running a successful tech business, so it is wise to be informed.
Marketing can be an uncomfortable undertaking, especially if your material is technology based. Luckily, we’ve compiled some simple and (relatively) painless tips to put an end to your trepidation and start your path to success.
Viewers will get an overview of the benefits and risks of using Bitcoin to accept payments. What Bitcoin is: Legality: Risks: Benefits: Which businesses are best suited?: Other things you should know: How to get started:
An overview of how to create reports in Adobe Analytics (formerly Omniture Site Catalyst) using pageNames, events, eVars and props. This video will show you how to install the Omniture Debugger tool so can see (and test) what is being passed int…

821 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