Jump to content

[SOLVED] How to Auto sort a database output into a php page


wpatters1229

Recommended Posts

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;

?>

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.