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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T23:12:44+00:00 2026-05-20T23:12:44+00:00

i have 29 rows in mytable with datetime(dt). I want to sort it in

  • 0

i have 29 rows in mytable with datetime(dt). I want to sort it in descending order
when i query the table it give the result starting from 28 (29 not given) and after 28 it starts from 1, 2….27 where
(1-27 datetime is 0000-00-00 00:00:00) and 29 has the recent time.


$dt1=$_GET['dt'];
$query="SELECT * FROM table ORDER BY dt DESC";
$result1 = mysql_query($query);
$table = mysql_fetch_array($result1, MYSQL_ASSOC);
$dt2=$table['dt'];
echo $dt2."
"; // if here i echo $table['id']; the result is here 29 if(strtotime($dt1) < strtotime($dt2)) { while ($table = mysql_fetch_array($result1, MYSQL_ASSOC)){ echo $table['id']."<br />"; echo $table['name']."<br />"; } } else echo "false";

Why the last id is not shown i.e 29

  • 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-20T23:12:45+00:00Added an answer on May 20, 2026 at 11:12 pm

    You read your first line into $table on line 3

    $result1 = mysql_query($query);
    

    So when entering your while loop you read the second row into $table causing you to miss the first row.

    EDIT :
    You can prevent this by resetting the rowpointer right before you start your while loop like this:

    mysql_data_seek($query,0);
    while(..........
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to display a ListView in table format. The ListView should have rows
I have the following table (contains over a million rows): **MyTable** id - int(10)
What's the best way to select only those rows from the table that have
I have 7 rows in my table like Date1,Date2... they´re all dateTime, and i
I have a simple table with 1,000,000 rows. this row has a datetime field
I have a MySQL table like this: CREATE TABLE IF NOT EXISTS `mytable` (
I have two columns in my table and the rows are created dynamically. <table
I have a datagridview that may or may not have rows selected when the
I have selected rows based on DateTime before using either: DATEADD(day, -1, GetDate()) AND
I have a HTML table which I add items to from javascript on an

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.