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 4564014
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T18:26:28+00:00 2026-05-21T18:26:28+00:00

So I am picking up a project that was quit halfway through by the

  • 0

So I am picking up a project that was quit halfway through by the last guy so that I could get some more practice with PHP and databases. I have run into a problem, and I am sure it is common enough that there is a standard solution, but I am unable to find one.

The db I am working with has 4,600, so reorganizing is out of the question. It is a db of liquers for a wholesaler. Here is what the results page looks like currently:
enter image description here

What I am trying to set it up so the results are returned in list form, with only one title and dropdown menus for the different sizes/prices of products that looks like this:

enter image description here

The problem is that there are multiple entries in the db for each product. In this example there are 3, while some have 1, and some have 2.

I am really not sure how to go about this, and any help would be greatly appreciated. Thank you.

  • 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-05-21T18:26:29+00:00Added an answer on May 21, 2026 at 6:26 pm

    I’m not sure about the PHP syntax, but pseudocode here’s what you could do:

    allProductsReturnedFromMySQL = QueryYourDatabaseForAllProducts()
    Hashtable[productId, List[productSizes]] dropDownsByProduct;
    Hashtable[productId, commonProductInformation] uniqueProducts;
    
    foreach (product in allProductsReturnedFromMySQL) {
        if product.productId not in uniqueProducts
            then add it with the product information that does not vary
    
        if product.productId not in dropDownsByProduct
            then add it with an empty list
    
        append the size of this product to the corresponding list in dropDownsByProduct
    }
    

    After that little bit of logic you’ll have all your unique products with the common properties for each one, and a way to fetch the corresponding sizes drop down. If you wanted to do this purely in SQL to minimize the data that’s transferred, you could do something like this:

    -- this would get you your products
    select distinct id, property1, property2 from product
    
    -- this would get you your drop downs by product
    select id, size from product order by id
    

    You can then build the same drop down hashtable by iterating through the second result set.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am picking my way through some c# code I inherited, and trying to
I have some down time and I am think of picking a new project
I have this VB.Net 1.1 project that I have to make some changes to.
Visual Studio 2008 is not picking up the MVC 1.0 project templates. The MVC
I'm considering picking up some very rudimentary understanding of assembly. My current goal is
I have noticed some developers picking up new skills and moving from one platform
An application that has been working well for months has stopped picking up the
Is there any evidence to suggest that by manually picking which processor to run
I am working on a project that parses an incoming text file. I am
I am picking up maintenance of a project and reading code: I see two

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.