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

  • Home
  • SEARCH
  • 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 8978275
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T19:34:18+00:00 2026-06-15T19:34:18+00:00

Ok so my SQL query is: $image_results = $wpdb->get_results(‘SELECT * FROM uploaded_images GROUP BY

  • 0

Ok so my SQL query is:

$image_results = $wpdb->get_results('SELECT * FROM uploaded_images GROUP BY album_title') ;

What I now want to do is have a different set of results for each different *album_title* that outputs the album title in a tag and then show a list of items that have that album title.

Here is what i have so far:

<?php foreach ($image_results as $result => $coll):?>
    <h4><?php echo $coll->album_title;?></h4>
    <?php foreach ( $coll->file_name as $i => $row ) : ?>
         <p><img src="http://example.com/<?php echo  $row->file_name; ?>"/></p>
    <?php endforeach; ?>
<?php endforeach; ?>
  • 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-15T19:34:19+00:00Added an answer on June 15, 2026 at 7:34 pm

    After your question update, I think this is what you are looking for. Note that I have used ORDER BY instead of GROUP BY. Grouping is used when things like SUM, AVG, or other aggregate functions are used. This can be handled all in one loop:

    $image_results = $wpdb->get_results('SELECT * FROM uploaded_images ORDER BY album_title');
    $curTitle = '';
    foreach($image_results as $result => $col) {
        if($curTitle !== $col['album_title']) {
            $curTitle = $col['album_title'];
            echo "<h4>$curTitle</h4>";
        }
        echo '<p><img src="' . $col['file_name'] . '" /></p>';
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

SQL query: SELECT ArticleCategories.Title AS Category, Articles.Title, Articles.[Content], Articles.Date FROM ArticleCategories INNER JOIN Articles
SQL query which select the record from three tables and there is no relation
Original SQL query is this; SELECT id,post_title,post_date FROM wp_posts where id='1' When I retrieve
My sql query is as follows IF @StatusId = 10 BEGIN SELECT * FROM
Hello i've the following SQL Query which produces the following result SELECT * FROM
I have this query: select top(2) property_id_ref ,image_file ,property_name from property_master a inner join
I have the following SQL query SELECT tbl_product.prod_id, ISNULL (prod_code, '') AS prod_code, ISNULL
I have an image data type in my table. When I query using SQL
I have this query and I have an error: images = Image.find_by_sql('PREPARE stmt FROM
My SQL query looks like this... sekect * FROM mail_headers a LEFT JOIN mail_headers_body

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.