Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8567297
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T17:51:01+00:00 2026-06-11T17:51:01+00:00

I have a product feed that lists clothing items multiple times, once each for

  • 0

I have a product feed that lists clothing items multiple times, once each for every colour and size that the item is available in.

ProductID      Product Name               Colour      Size      Price

1              Men's Board Shorts         Blue        S         4.99
1              Men's Board Shorts         Blue        M         4.99
1              Men's Board Shorts         Blue        L         5.99
1              Men's Board Shorts         Red         S         4.99
1              Men's Board Shorts         Red         M         4.99
1              Men's Board Shorts         Red         L         5.99

I have two tables: One for the name & ID and another table for the id, colour, size and price for each product.

In the first table, I only want the name of the product to appear ONCE for each product, irrespective of the number of different sizes and colours. In the second table I want the product’s ID code, the size and price to appear for each of the different colours that are available.

So I would end up with the following data:

Product Table
1     Men's Board Shorts

Options Table
1     Blue     S         4.99
1     Blue     M         4.99
1     Blue     L         5.99
1     Red      S         4.99
1     Red      M         4.99
1     Red      M         5.99

The reason for separating the sizes into individual records instead of have size S,M,L in one field is that sometimes the price for the large item is different to the price for the small and medium sized items.

Any ideas to get me started/pointed in the right direction?

Thanks…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T17:51:01+00:00Added an answer on June 11, 2026 at 5:51 pm

    Creation of the 2 tables:

     CREATE TABLE product (
      id INT NOT NULL PRIMARY KEY,
      name VARCHAR() NOT NULL
      );
     CREATE TABLE options (
      product_id INT NOT NULL PRIMARY KEY,
      color VARCHAR(30),
      size VARCHAR(10),
      price DECIMAL(10,2)  
     );
    

    Fetching & inserting records in the tables:

     $result1 = mysql_fetch_assoc(mysql_query('SELECT * from ProductTemp GROUP BY ProductID', $conn));
    
     $result2 = mysql_fetch_assoc(mysql_query('SELECT * from ProductTemp', $conn));
    
     foreach( $result1 as $v ) {
      $retval1 = mysql_query("INSERT INTO product VALUES('$v['ProductID']','$v['Product Name']')", $conn);
      if(!$retval1) {
      echo 'Could not enter data into table product: ' . mysql_error(); 
      exit;
     }
     }
    
      foreach( $result2 as $v ) { 
     $retval2 = mysql_query("INSERT INTO options VALUES('$v['ProductID']','$v['Color']','$v['Size']' , $v['Price'])", $conn); 
    
    if(!$retval2 ) {
      echo 'Could not enter data into table options: ' . mysql_error(); 
      exit;
     }
     } 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have product item webpages located in /product/items/*.html?id=12345&ref=54321 and I would like the webpages
I have a feed that gives me times (not datetimes) in this format: 20:00:00.000+03:00
I have a product that has multiple variations. I would like, in an RSS
I have a product in mind that requires the development of a website that
I have a Product Service. On each call to Service, I want to call
I have a product setup executable that copies some files to the user's hard
I will try and ask my question clearly... I have three tables that each
I have built a site that relies on an XML feed that I currently
have this code: $products = $feed->_xpath->query( //cf:vehicle ); foreach( $products as $product ) {
I am trying to build a rake tasks, that fetches a product feed and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.