Solved

Need to create a dynamically populated dropdown box for selling shoes

Posted on 2006-06-22
5
175 Views
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.
0
Comment
Question by:AirCarter15bh
  • 2
5 Comments
 
LVL 21

Expert Comment

by:Julian Matz
Comment Utility
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
 

Author Comment

by:AirCarter15bh
Comment Utility
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
 
LVL 21

Accepted Solution

by:
Julian Matz earned 250 total points
Comment Utility

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

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

This story has been written with permission from the scammed victim, a valued client of mine – identity protected by request.
Every business owner understands the significance of online customer reviews and the impact it can have on sales and revenues. With technology advancing at such a rapid pace, getting online reviews has never been easier, especially when many regions…
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…

772 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

11 Experts available now in Live!

Get 1:1 Help Now