Jump to content

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.

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.