Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 202
  • 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.
0
AirCarter15bh
Asked:
AirCarter15bh
  • 2
1 Solution
 
Julian MatzCommented:
I can give you some guidance for php/mysql...

<?php
$connection = mysql_connect('localhost','username','password') or die ( mysql_error() );
mysql_select_db('name_of_database');

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

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


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...
0
 
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.
0
 
Julian MatzCommented:

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
 //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 - www.php.net.

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:

<?php
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 .example.com/test.php

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

Featured Post

Industry Leaders: 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!

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