Forum Moderators: coopster

Message Too Old, No Replies

selecting sizes with php

         

adamnichols45

1:13 pm on Nov 26, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I need to add products to a database.

with sizes i have in stock ie large medium and small.

whats the best way todo this.

then i want to populate a drop down menu with all the sizes in stock im not sure how to go about this.

thanks for any help.

chriswragg

4:13 pm on Nov 26, 2005 (gmt 0)

10+ Year Member



You could have a Sizes table, which contains a productid, size, price etc. and create a sql statement to select where productid is equal to the id of the product on the current page.

As for the drop down box, you would just create a while loop to echo <option> tags for each size:


//Mysql Stuff
$num = mysql_num_rows($result);
$x = 0;
while($x<$num){
$size = mysql_result($result,$x,"size");//Get your size value
echo "<option value=".$size.">".$size."</option>";
$x++;
}

(That may not be entirely accurate)

Chris