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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T11:32:53+00:00 2026-06-11T11:32:53+00:00

I have two tables… project table +—-+——–+ | id | client | +—-+——–+ |

  • 0

I have two tables…

project table

+----+--------+
| id | client |
+----+--------+
|  1 | James  |
|  2 | John   |
+----+--------+   

images table

+----+-----------+-------------------+
| id | projectId |     imagePath     |
+----+-----------+-------------------+
|  1 |         1 | images/image1.jpg |
|  2 |         1 | images/image2.jpg |
|  3 |         2 | images/image3.jpg |
|  4 |         2 | images/image4.jpg |
|  5 |         2 | images/image5.jpg |
+----+-----------+-------------------+

As you can see, one project has many images. I want to display that
this way…

James

images/img1.jpg
images/img2.jpg

John

images/img3.jpg
images/img4.jpg
images/img5.jpg

This post gave me what I want https://stackoverflow.com/a/2451065/1214535

But when I echo like so

<img src='".$row['imagePath']."/>

the results in image tag I get this

<img src="images/img3.jpg,images/img4.jpg,images/img5.jpg">

instead of

<img src="images/img3.jpg"/> 
<img src="images/img4.jpg"/>
<img src="images/img5.jpg"/>

How can I change the query so that I can display the images properly/separately

this is the query I am using

$sql="SELECT images.projectId,project.client,
GROUP_CONCAT(images.imagePath SEPARATOR ', ') 
AS 'imagePath' 
from project left JOIN images on project.id=images.projectId 
GROUP BY project.id ASC";

thank you guys…

  • 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-11T11:32:54+00:00Added an answer on June 11, 2026 at 11:32 am

    You could try using foreach to loop through different values.

    Syntax:

    foreach (array_expression as $value)
        statement
    

    First insert all the values you get in an array like this:

    $imgArray = explode(',',$row['imagePath']);
    

    Then loop through this array as:

    foreach ($imgArray as $img)
    {
     echo "<img src='$img'" />";
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two tables: table a ida valuea 1 a 2 b 3 c
I have two tables one with ID and NAME table 1 ID | NAME
I have two tables user table user_id | name | 1 | peter |
I have two tables, a user table and a application table: User id username
I have two tables connected with one to many relationship. Parent Table is a
I have two tables with this structure: Table one: ID Description Table two: ID
I have two tables. Table Emp id name 1 Ajay 2 Amol 3 Sanjay
I have two tables CREATE TABLE table1 (id int primary key auto_increment,....); CREATE TABLE
I have two tables. One table contains information about Assets, another Table about their
I have two tables. One is temp table and another is main table. In

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.