wpatters1229 Posted July 29, 2009 Share Posted July 29, 2009 I have this code in the head of a php page and it contacts a database and pulls the results onto the page. I want to auto sort the AGE column so it always is in the right order no matter how the entries are entered into the database. Anyone know how to add that to this code: <?php require_once('../connections/xxxxxxxxxxxxxx.php'); ?> <?php $maxRows_Recordset1 = 999; $pageNum_Recordset1 = 0; if (isset($_GET['pageNum_Recordset1'])) { $pageNum_Recordset1 = $_GET['pageNum_Recordset1']; } $startRow_Recordset1 = $pageNum_Recordset1 * $maxRows_Recordset1; mysql_select_db($database_aba, $aba); $query_Recordset1 = "SELECT * FROM florida_civil_war"; $query_limit_Recordset1 = sprintf("%s LIMIT %d, %d", $query_Recordset1, $startRow_Recordset1, $maxRows_Recordset1); $Recordset1 = mysql_query($query_limit_Recordset1, $aba) or die(mysql_error()); $row_Recordset1 = mysql_fetch_assoc($Recordset1); if (isset($_GET['totalRows_Recordset1'])) { $totalRows_Recordset1 = $_GET['totalRows_Recordset1']; } else { $all_Recordset1 = mysql_query($query_Recordset1); $totalRows_Recordset1 = mysql_num_rows($all_Recordset1); } $totalPages_Recordset1 = ceil($totalRows_Recordset1/$maxRows_Recordset1)-1; ?> Quote Link to comment https://forums.phpfreaks.com/topic/167886-solved-how-to-auto-sort-a-database-output-into-a-php-page/ Share on other sites More sharing options...
xtopolis Posted July 29, 2009 Share Posted July 29, 2009 Probably this line right here: $query_Recordset1 = "SELECT * FROM florida_civil_war"; To something like this: $query_Recordset1 = "SELECT * FROM florida_civil_war ORDER BY nameOfAgeColumn"; Where "nameOfAgeColumn" is the name of the column that stores the age. Quote Link to comment https://forums.phpfreaks.com/topic/167886-solved-how-to-auto-sort-a-database-output-into-a-php-page/#findComment-885532 Share on other sites More sharing options...
wpatters1229 Posted July 29, 2009 Author Share Posted July 29, 2009 Yes!!! I used to work with cold fusion many years ago and now that all makes sense. I guess asking my brain to work at the end of the day is beyond expectations....at my age I should know better. Thanks Quote Link to comment https://forums.phpfreaks.com/topic/167886-solved-how-to-auto-sort-a-database-output-into-a-php-page/#findComment-885563 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.