I have an html table that is populated using a text file only and is basically sorted primarily by a timestamp. I would like the option of also sorting the table data by a column ($keys) called "Server" so I can view sorted data based on the server name. Since this is not using mysql and I can't use an 'order by', is there a way to do accomplish this? How do you do this in php?
Here is some of my code showing how my table is created:
$keys = array('Server', 'Target','Set','Time', 'Length','Size','Status');
echo '<table id="stats_1"><tr>';
foreach ($keys as $column)
echo '<th>' . $column . '</th>';
echo '</tr>';
$counter=0;
foreach ($data as $row){
$counter ++;
$class = $counter % 2 === 0 ? 'alt1' : 'alt2';
echo '<tr class="' . $class . '">';
foreach ($keys as $column){
if (isset($row[$column])){
echo '<td>' . $row[$column] . '</td>';
} elseif ($column == 'Status') {
echo '<td> Check Logs </td>';
} elseif ($column == 'Length') {
echo '<td> n/a </td>';
} elseif ($column == 'Size') {
echo '<td> n/a </td>';
} else {
echo '<td> </td>';
}
}
}
echo '</table>';