Hi! I have a php script that I have managed to create to display a list of trainees and their companies. I have it set to sort by name with ASC by default. I would like to have it so that when I click on "Trainee" that it will sort by DESC (or ASC depending on which on it currently is displaying). I have attached a screenshot for visual effect of my needs, and the code is below. Any help would be greatly appreciated. Thanks!
Jeff
$type_desc_array = array(1 => "Logging", 2 => "Transportation", 3 => "Logging & Transportation");
$title = 'Trainee Administration';
require_once($docsroot."header_training.php");
if ($_SESSION["sl"] > 1) {
// View Only users cannot change things, so let's disable some functionality.
$field_disabled = 'disabled';
}
echo '<div style="border-bottom: 1px solid #002902;color:#002902;margin-bottom:5px;font-size:16px;font-weight:bold;">Trainee Administration</div><br>';
if (((!$keywords)) && ($_POST["submit"] != 'Edit Trainee') && ($_POST["submit"] != 'Add Trainee') && ($_GET["action"] != 'edit') && ($_GET["action"] != 'add')) {
$query_trainees = "SELECT * FROM tdb_trainees ORDER BY tdb_trainees.last_name ASC";
//echo $query_trainees."<br>";
$result_trainees = mysql_db_query($dbname, $query_trainees);
while ($r = mysql_fetch_array($result_trainees)) {
$trainee_id = $r["trainee_id"];
$last_name = $r["last_name"];
$first_name = $r["first_name"];
$producer_id = $r["producer_id"];
$phone1 = $r["phone1"];
$query_producer = "SELECT name FROM tdb_producers WHERE producer_id='".$producer_id."'";
$result_producer = mysql_db_query($dbname, $query_producer);
list($producer_name) = mysql_fetch_array($result_producer);
if (strlen($producer_name) > 30) {
$producer_name = substr($producer_name, 0, 30)."...";
}
$trainees_list_output .= '
<tr>
<td valign="top"><br><a href="/training/trainees.php?action=edit&trainee_id='.$trainee_id.'">'.$last_name.', '.$first_name.'</a></td>
<td valign="top"><br>'.$producer_name.'</td>
<td valign="top"><br>'.$phone1.'</td>
</tr>';
}
echo '<table width="580" align="right" border="0" cellspacing="0" cellpadding="0">
<tr>
<td colspan="3">
<i>NOTE: Click the trainee name to edit/delete a trainee, or <a style="text-decoration:underline" href="/training/trainees.php?action=add&pid='.$producer_id.'">Add a New Trainee</a> here.</i><br> </td>
</tr>
<tr>
<td width="210" valign="top"><u>Trainee Name</u>:</td>
<td width="260" valign="top"><u>Company</u>:</td>
<td width="110" valign="top"><u>Phone</u>:</td>
</tr>
'.$trainees_list_output.'
</table>';
}
MOD EDIT: [noparse]
..
[/noparse] bbcode tags replaced with [noparse]
..
[/noparse] bbcode tags.