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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T05:27:53+00:00 2026-05-24T05:27:53+00:00

I have 2 tables in My database and I wanted a PHP output of

  • 0

I have 2 tables in My database and I wanted a PHP output of the following, how can I do this?

Latest 5 Catname1 Images
image42.jpg, image45.jpg ect ect

Latest 5 Catname2 Images
image41.jpg, image44.jpg ect ect

Latest 5 Catname3 Images
image43.jpg, image46.jpg ect ect

I have 2 tables in mysqly layed out like this:

imagedb (MySql Table name)
iid,iname,icat,idesc,itags,ithumb
41,Name41,2,desc41,tag41,image41.jpg
42,Name42,1,desc42,tag42,image42.jpg
43,Name43,3,desc43,tag43,image43.jpg
44,Name44,1,desc44,tag44,image44.jpg
45,Name45,2,desc45,tag45,image45.jpg
46,Name46,3,desc46,tag46,image46.jpg
Ect ect

categories (MySql Table name)
cid,cname,cdesc,ctags
1,catname1,catdesc1,cattags1
2,catname2,catdesc2,cattags2
3,catname3,catdesc3,cattags3

Hope this makes sense. 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-24T05:27:54+00:00Added an answer on May 24, 2026 at 5:27 am

    The simplest thing to do would be to create a loop in PHP that fetches the last 5 images from the imagedb table based on each category you want to use.

    $categories = mysql_query("SELECT cid, cname FROM categories");
    while($row = mysql_fetch_assoc($categories)){
        echo "<strong>Latest 5 " . $row['cname'] . " Images</strong>";
        $image_query = mysql_query("SELECT * FROM imagedb WHERE cid = " . $row['cid'] . " ORDER BY iid DESC LIMIT 5;");
        $images = array();
        while($image = mysql_fetch_assoc($image_query))
            $images[]  = $image['iname']; // change this to $image['ithumb'] etc for different fields
    
        echo '<p>' . implode(', ', $images) . '</p>';
    }
    

    That will print pretty closely what you have entered there, (assuming the ID of each image indicates when it was inserted (higher means newer).

    There are probably cleaner ways of doing this, and depending on your implementation you might need to loop once to get the data then again to print it, however this should give you a good headstart.

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

Sidebar

Related Questions

I have 2 tables in my database and I wanted a PHP output of
I have two database tables with the following structure: actions: action_id int(11) primary key
I have four tables in database. person(Perid ,firstname , lastname , gender) Research (Resid
I have two database tables, 1st is the TABLE_GLOBAL_PRODUCTS where all products information are
In the database we have tables called Sites, Organisations, Person, Department have the same
I have 3 database tables, all of them have the same 5 columns. They
I have several database tables that just contain a single column and very few
I have three database tables: users emails invitations Emails are linked to users by
I have 2 tables in my database, for example: Table1: id (PK), data1 and
I have such tables in my database like Customer , Member , Instructor ,

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.