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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T05:29:50+00:00 2026-06-01T05:29:50+00:00

i have a online application for wich i require a sort of dashboard (to

  • 0

i have a online application for wich i require a sort of dashboard (to use the white-space).

There are three tables used for the operation:

1.) categories: id, name
2.) entries: id, name, description, category_id, created, modified
3.) entryimages: id, filename, description, entry_id

on the dashboard i want to show 4-5 entries (with thumbnail images, so i require joins to the entryimages table and the categories table) for each category.

I read through some articles (and threads on s.o.) like this one:
http://www.xaprb.com/blog/2006/12/07/how-to-select-the-firstleastmax-row-per-group-in-sql/

But am still not getting it right, i’ve tried to first extract all categories and for each and every category build a query and with “all union” attach them to one, but that is not working.
The last version of code i used:

foreach($categories as $id => $name)
{
    $query .= "SELECT   `entry`.`id`,
            `entry`.`name`,
            `entry`.`description`,
            `entry`.`category_id`,
            `entry`.`created`,
            `entry`.`modified`,
            `entryimages`.`filename`,
            `entryimages`.`description`
            FROM `entries` as `entry` LEFT JOIN `entryimages` ON `entryimages`.`entry_id` = `entry`.`id`
WHERE `entry`.`category_id` = $id ";

            if($i < count($groups))
            {
                $query .= 'UNION ALL ';
            }

            $i++;
        }

        $result = mysql_query($query);

Does anybody know what is the best right to accomplish this operation?

Thanks 1000

  • 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-01T05:29:51+00:00Added an answer on June 1, 2026 at 5:29 am

    On the dashboard if you want to show three entries, the way you are doing is wrong. If my understanding is right, the entire query will be something like

    "SELECT `entry`.`id`,
            `entry`.`name`,
            `entry`.`description`,
            `entry`.`category_id`,
            `entry`.`created`,
            `entry`.`modified`,
            `entryimages`.`filename`,
            `entryimages`.`description`
        FROM `entries` as `entry` 
        INNER JOIN categories 
            ON (entry.category_id = categories.id)
        LEFT JOIN (SELECT * FROM `entryimages` WHERE `entry_id` = `entry`.`id` LIMIT 1) AS `entryimages`
            ON `entryimages`.`entry_id` =`entry`.`id`    
        ORDER BY `entry`.`created` DESC LIMIT 5";
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an online application that all of its pages use HTTPS. I have
I use C# to write a (hypothetical) application - online store. I have a
I'm doing an online judge application, so I have a User model, a Problem
i have website of application which sells applications online.on the home page i want
I have finally gotten my login application to function with my online database. I
I have to include one report in my application showing offline/online activity of few
We have online SharePoint site and we want to use tool or any way
I have a online shopping cart, at checkout user enters his zipcode. There are
I have an online application with PHP & MySQL. I need to provide some
Hello guys i have an website online wich access the database. The database access

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.