Improve company productivity with a Business Account.Sign Up

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 207
  • Last Modified:

Need to create a dynamically populated dropdown box for selling shoes

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.
  • 2
1 Solution
Julian MatzJoint ChairpersonCommented:
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...
AirCarter15bhAuthor Commented:
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.
Julian MatzJoint ChairpersonCommented:

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...".
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

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now