Hello guys I'm wondering whether someone can help me to change the sorting from oldest to latest data into latest to oldest data sorting? I have a database of users which are added after they fill a form, and I created a page where I can see these users from the database but I'm always seeing starting from the first ID to latest so what I want to do is to change to latest ID to oldest data, here is my code can someone help? Thanks <?php mysql_connect("localhost", "user", "password") or die ("Problem with Connection..."); mysql_select_db("database"); $per_page = 20; $pages_query = mysql_query("SELECT COUNT('id') FROM table"); $pages = ceil(mysql_result($pages_query, 0) / $per_page); $page = (isset($_GET['page'])) ? (int)$_GET['page'] : 1; $start= ($page - 1) * $per_page; $query = mysql_query("SELECT * FROM users LIMIT $start, $per_page"); Then I echo the values on a table format starting with the first ID.... echo "<table width=\"90%\">"; echo "<tr><th>ID</th> .....
$query = mysql_query("SELECT * FROM users LIMIT $start, $per_page ORDER BY ID DESC"); PHP: Think this should do it
Thanks buddy, I needed to change it a little bit but I got it now $query = mysql_query("SELECT * FROM users ORDER BY id DESC LIMIT $start, $per_page");