Jump to content

Need to reverse the results...


peerData

Recommended Posts

I am trying to display, well I have succeeded in doing to, the information from a DataBase Table. However I need to reverse the displaying so that it shows the Newest entries first and the Oldest entries last. Below is the code I have. Any assistance in this would be much appreciated.

 

mysql_connect("localhost", "username", "password") or die(mysql_error());

mysql_select_db("database") or die(mysql_error());

$data = mysql_query("SELECT * FROM post")

or die(mysql_error());

Print "<table border=0 cellpadding=0>";

while($result = mysql_fetch_array( $data ))

{

Print "<tr bgcolor=grey>";

Print "<td>ID: ";

Print "".$result['id'] . "</td></tr>";

Print "<td>Date Submitted: ";

Print "".$result['day'] . " - ";

Print "".$result['month'] . "  ";

Print "".$result['date'] . ", ";

Print "".$result['year'] . "</td></tr>";

Print "<td>Submitted by: ";

Print "".$result['name'] . "</td></tr>";

Print "<td>Topic: ";

Print "".$result['topic'] . "</td></tr>";

Print "<td>Subject: ";

Print "".$result['subject'] . "</td></tr>";

Print "<td>Info Given: ";

Print "".$result['info'] . "</td></tr>";

Print "<td>Issue Resolved: ";

Print "".$result['resolved'] . "</td></tr>";

Print "<td>";

Print "<hr>" . "</td></tr>";

}

Print "</table>";

 

Link to comment
Share on other sites

try:

mysql_query("SELECT * FROM post ORDER BY date DESC")

 

I done this, cleared my data and tried again,

I got

 

2nd Submit: 70

3rd Submit: 71

4th Submit: 72

1st Submit: 69

 

Since the ID is autoinc I changed the date to id and it is now showing correctly.

 

So instead of

mysql_query("SELECT * FROM post ORDER BY date DESC")

I have

mysql_query("SELECT * FROM post ORDER BY id DESC")

 

And now to the next task at hand.

 

Thank You VERY much!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.