Okay, Lets see if I can aswer all of your questions.
Your question regarding how you could display the products colors for that single product.
Create a color and size table. For the price I would put the price with the product information.
For every color have a productID. For Example you could do:
CREATE TABLE colors (
color_id MEDIUMINT(8) NOT NULL AUTO_INCREMENT,
color_text VARCHAR(85) NOT NULL,
product_id MEDIUMINT(8) NOT NULL DEFAULT '0',
PRIMARY KEY color_id(color_id)
);
Do the same with the size.
Now when pulling information from the database to display on the drop down you can do somthing like this.
Code:
<?php
//Id number - I am assuming its from a GET variable
$id=$_GET['id'];
//Do all of your mysql connections
//Do query
//s=size, c=color, p=product
$query_colors="SELECT c.product_id,c.color_text,c.color_id,p.product_id,p.product_name,p.product_description FROM products AS p LEFT JOIN color c ON c.product_id=p.product_id WHERE p.product_id='$id'";
$query_size="SELECT s.product_id,s.size_text,s.size_id,p.product_id,p.product_name,p.product_description FROM products AS p LEFT JOIN size s ON s.product_id=p.product_id WHERE p.product_id='$id'";
//Run query;
$result=@mysql_query($query_color);
$result2=@mysql_query($query_size);
//Lets create the select
?>
<select name="color_size">
<?php
//Lets loop through the colors (only if there are some)
if(mysql_num_rows($result)==0){
}else{
while($row=mysql_fetch_array($result)){
?>
<option value="<?php echo($row['size_id']); ?>"><?php echo($row['size_text']); ?>
<?php
}
}
//Lets loop through the sizes
if(mysql_num_rows($result2)==0){
}else{
while($row=mysql_fetch_array($result2)){
?>
<option value="<?php echo($row['color_id']); ?>"><?php echo($row['color_text']); ?>
<?php
}
}
?>
</select>
Now when the user adds this item to the cart you can pull the color_id and size_id and match it in the mysql database.
I hope this answers some of your questions. I apologize if I have missed your entention.
