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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T11:15:16+00:00 2026-05-24T11:15:16+00:00

I can’t seem to figure out how to make a SELECT statement that group

  • 0

I can’t seem to figure out how to make a SELECT statement that group products and displays the products under one product type.

I have a table called floors containing 15 different floor products and a table called floortypes containing 8 different product types (ftid) and a product image.
Each of the 15 products have a floortype which define which type it is. Some of the products are almost the same but with different measurements which but it gives the products a different description.

Example:

Product: Product 1 Product type: 1
Product: Product 2 Product type: 1
Product: Product 3 Product type: 2
Product: Product 4 Product type: 2
Product: Product 5 Product type: 3
Product: Product 6 Product type: 4

What I want is to is the products to be displayed under a product group with 1 product image

Producttype 1 image
Product 1 description
Product 2 description 

Producttype 2 image
Product 3 description
Product 4 description  

Producttype 3 image
Product 5 description

Producttype 4 image
Product 6 description

I hope someone is able to help me!

EDIT

I used your first example which works flawlessly.
This is my final code:

$sql = SQLHandling::SQLquery("SELECT A.fid, A.floorname, A.desc_dk, A.floortype, B.prodimage, GROUP_CONCAT(A.desc_dk SEPARATOR '|') AS descr, GROUP_CONCAT(A.floorname SEPARATOR '|') AS fname FROM floors A JOIN floortypes B ON A.floortype = B.ftid GROUP BY A.floortype, B.prodimage");

and then my while loop:

$counter = 0;

while($row = mysql_fetch_array($sql)) {

    $delimiter = "|";
    $descr = explode($delimiter, $row["descr"]);
    $fname = explode($delimiter, $row["fname"]);

    $markers["###FLOOR###"] .= '<div style="float: left; width: 200px; height: 425px; margin: 0px 10px 0px 10px; vertical-align: text-top; text-align: left;">';    
    $markers["###FLOOR###"] .= '<p><a href="index.php?page=sfp&room='. $_GET["room"] .'&floor='. $row["floorname"] .'&wall='. $_GET["wall"] .'&envi='. $_GET["envi"] .'&fpanel='. $_GET["fpanel"] .'"><img src="images/floors/'. $row["prodimage"] .'.jpg" width="200" /></a></p>';

    for ($i = 0; $i < count($descr); $i++) { 
        $markers["###FLOOR###"] .= '<p><a href="index.php?page=sfp&room='. $_GET["room"] .'&floor='. $fname[$i] .'&wall='. $_GET["wall"] .'&envi='. $_GET["envi"] .'&fpanel='. $_GET["fpanel"] .'">'. $descr[$i].'</a></p>';
    }

    $markers["###FLOOR###"] .= '</div>';

    if (++$counter % 4 == 0) {
        $markers["###FLOOR###"] .=  '<div style="clear: both;">&nbsp;</div>';
    }
}

gives me exactly what I was looking for!

  • 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-24T11:15:16+00:00Added an answer on May 24, 2026 at 11:15 am

    Maybe you are just looking for this ?

    SELECT B.ftid, B.prodimage, A.fid, A.floorname, A.desc_dk     
    FROM   floors A JOIN floortypes B 
    ON     A.floortype = B.ftid
    

    This will give a resultset as follows,

    producttype1, pt1image, product1 id, product1 name, product1 descriptin
    producttype1, pt1image, product2 id, product2 name, product2 descriptin
    producttype2, pt2image, product3 id, product3 name, product3 descriptin
    producttype2, pt2image, product4 id, product4 name, product4 descriptin
    producttype3, pt3image, product5 id, product5 name, product5 descriptin
    producttype4, pt4image, product6 id, product6 name, product6 descriptin
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can't figure out how to do this in a pretty way : I have
Can't work out a way to make an array of buttons in android. This
Can somebody point me to a resource that explains how to go about having
Can a LINQ enabled app run on a machine that only has the .NET
Can you suggest some good MVC framework for perl -- one I am aware
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
Can some one Guide me to work with these things... What is Model popup
Can anyone help me with an excel formula that groups related rows and creates
Can anyone help me trying to find out why this doesn't work. The brushes

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.