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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T09:29:29+00:00 2026-05-25T09:29:29+00:00

How can I display only the LAST 10 results from a mysql query? I

  • 0

How can I display only the LAST 10 results from a mysql query?

I want anything prior to the last 10 results to be ignored when the results are output.

<?php
$query = mysql_query("SELECT * FROM graphs WHERE sid=2 ORDER BY id");
while($info = mysql_fetch_array($query)){
    $graph_id = $info['id'];
    $graph_info = $info['labels'];
    $graph_fig = $info['figures'];

    echo "<label>" . $graph_info .":<span style='background-color: #06F;'>" . $graph_fig . "</span></label>";
}
?>

EDIT
I forgot to mention that the results must be displayed in ASCENDING order sorted by the id column.

  • 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-25T09:29:29+00:00Added an answer on May 25, 2026 at 9:29 am
    SELECT * FROM (SELECT * FROM graphs WHERE sid=2 ORDER BY id DESC LIMIT 10) g ORDER BY g.id
    

    Fetching last 10 records but resultset still in asc order.

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

Sidebar

Related Questions

How can i display variable only once in the table. <?php $sql = mysql_query(SELECT
The following code can only display the last number: for (i=0; i<3; i++) textbox.text({0},i);
How can I display only selected headers in DataGridView control? For example I have
How can I set all images in one line and display only the first
The code below working for only first div. I can't display other divs when
How can I set display:none to a ul if only has a single child?
I can display a simple Visual Basic inputbox from a PowerShell script like this:
i can only show last elemnts out of 10 records qlite3 *database; scores =
I was trying to develop a Chrome extension that can display me the last
i'm trying to connect query a database and display the results in a Spinner.

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.