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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T12:13:00+00:00 2026-05-23T12:13:00+00:00

I have a database with nearly 100 fields. DB structure is id | comment

  • 0

I have a database with nearly 100 fields.
DB structure is

id | comment | time

I need to fetch only 5 newest record (I can get those records using ORDER by time DESC). But while printing them I need to print the oldest of those 5 records first and proceed in reverse in a way that the newest record will be printed last.

  • 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-23T12:13:00+00:00Added an answer on May 23, 2026 at 12:13 pm

    Ok, after fetching result set in ascending order with a limit of number of rows

    you can do this to print them in reverse order (descending order)

    $data= array();
    while ($row = mysql_fetch_assoc($result)) {
        $data[] = $row;
    }
    
    $records = array_reverse($data);
    

    OR

    This could be done with mysql_data_seek

    Directly taken from here

    for ($i = mysql_num_rows($resultset) – 1; $i >= 0; $i–) {
        mysql_data_seek($resultset, $i);
        $row = mysql_fetch_assoc($result);
        echo $row['abc'] . ' ' . $row['xyz'] . "\n";
    } 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a field in a database that is nearly unique: 98% of the
I have Database with date field. I see the time like: 1900-01-01 13:38:00.000 How
I have a database table and one of the fields (not the primary key)
I have a 5-6 tables in my database that I need to populate with
I have nearly 15 SQL Instances names in the Database combobox of SQL Management
Can anyone help, I have 2 applications and they are nearly identical. they have
Our SQL Server 2005 database has nearly 100 different tables. We are going to
I have a Zend Application with user authentication. I need the UserID in nearly
I have group of checkboxes nearly equals to 100 all are with name checkbox1...checkbox1oo.
I have an extremely large database table - nearly 20 million records. The records

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.