Jump to content


This topic is now archived and is closed to further replies.


Size Chart and List/menu

Recommended Posts

Hello all!

I have this webshop today that i'm using. everything works fine until i decided that want my customers to be able to chose size and colors of the products. Now the problem is every products can have diferent sizes and colors compared to others.

My question is how can i make a MYSQL table and what can i do to solve this problem. Today i'm using a newby variable thing that i don't even wanna show because it sux.

If any of you have good solutin for this please let me know.

Thank you

Share this post

Link to post
Share on other sites
Id go for something like this...

[tr][td]1[/td][td]UKSHOE[/td][td]UK Shoe Sizes[/td][/tr]
[tr][td]2[/td][td]EUROPESHOE[/td][td]European Shoe Sizes[/td][/tr]
[tr][td]3[/td][td]UKMALEWAIST[/td][td]Male waist size UK[/td][/tr]
[tr][td]4[/td][td]UKFEMALESKIRT[/td][td]Female skirt size UK[/td][/tr]
[tr][td]5[/td][td]UKMARKET[/td][td]Standard UK Market size[/td][/tr]


This is your existing product table... Just add a 'size' column linked to the UniqueID of the SizeType table
[tr][td]1[/td][td]Nike Air Max[/td][td]1[/td][td]Red[/td][td]35.00[/td][/tr]
[tr][td]2[/td][td]Nike Air Zoom (US)[/td][td]2[/td][td]Blue[/td][td]40.00[/td][/tr]
[tr][td]3[/td][td]Silk Skirt[/td][td]4[/td][td]Black[/td][td]22.00[/td][/tr]
[tr][td]4[/td][td]Mens Cargo Trousers[/td][td]3[/td][td]Khaki[/td][td]37.00[/td][/tr]

You can add an additional table in there for specific product sizes.  e.g. if Nike Air Zoom (US) only come in size 43.


Share this post

Link to post
Share on other sites
ok! looks pretty good
So if i want a product that i only have in S and M only what do i do then?
Yeah also i want it to be a List drop down menu to choose the sizes.

Share this post

Link to post
Share on other sites
Maybe another table similar to this:


I'm not sure this is 100% effecient, but it should work.  QuantityID is another unique value, QProdID is linked to your ProductID in your product table, QSizeID is linked to SizeID in your Sizes table and quantity is the amount you have.

That way you could only display the sizes of what you have in stock.  Some SQL something similar to this...

FROM Sizes
    FROM ProductQuantity
    WHERE QProdID = '$ProductID'
    AND Quantity != 0)

$ProductID is the variable passed from into the search from PHP.

I'm sure some DB experts could point you in a better direction, but this should work.


Share this post

Link to post
Share on other sites
As you edited your post to include how you'd create the HTML for it, I'll have a stab at that too...

Lets say that you're information is going to be displayed on productdetail.php which is passed the ProductID in the URL from a previous page.

if (!isset($_POST['ProductID'])){
  header('Location: home.php'); // Lets redirect our users if they enter our page without a ProductID.
  $ProductID = $_POST['ProductID'];
  include("connect.php"); // Include your connection strings in this seperate file
  $query = "SELECT Size FROM Sizes WHERE SizeID IN (SELECT QSizeID FROM ProductQuantity WHERE QProdID = '$ProductID' AND Quantity != 0)";

  $result = mysql_query($query); // Execute the query
  if (!$result){
      die('Could run query: ' .mysql_error());

  while ($sizes = mysql_fetch_array($result, MYSQL_ASSOC)){  // While there are still rows, do this ...
      $option[]=$sizes["Size"]; //push the rows into a new array (we can do this as we know we're only selecting one column)

  echo "<select name=\"sizes\">";
  foreach ($option as $size){
      echo "<option value=\"$size\">$size</option>\n"; // echo each individual item in the $option array
  echo "</select>";

  include("disconnect.php"); // Include your disconnect details in a seperate file

This should give you the values in a drop down list.


Share this post

Link to post
Share on other sites


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.