I have a PHP file where I am populating a table from MySQL data, using array format to gather the information. I have headers on my table, and I would like to sort the table after clicking a specific header. How can I do that?
This is my running the query and getting the data into an array.
$results=$db_link->query($query);
while($row = $results->fetch_assoc()) {
$project_data[$row[id]][id] = $row[id];
$project_data[$row[id]][billable] = $row[billable];
$project_data[$row[id]][pugh_project] = $row[pugh_project];
$project_data[$row[id]][name] = $row[address2]." ".$row[name];
$project_data[$row[id]][project_num] = $row[project_num];
$project_data[$row[id]][budget] = $row[budget_hours_pm] + $row[budget_hours_eng] + $row[budget_hours_des] + $row[budget_hours_cad] + $row[budget_hours_tech];
}
This is the way I have my headers using HTML.
<div class="grid_12">
<table class="contact_list_table">
<tr class="contact_list_top_table">
<td width="100px" style="color:white">Project #</a></td>
<td style="color:white">Project Name</td>
<td style="color:white">Budget Hours</td>
<td style="color:white">Actual Hours</td>
<td style="color:white">Estimate to Complete</td>
<td style="color:white">Budget at Completion</td>
<td style="color:white">Performance (%)</td>
</tr>
How can I make it so that I can click on a header (eg. Project Name), and refresh the page with the proper sorting??