I want to display table by default in ascendind order with dynamically changing header.
Here is my code. It is displaying the rows unordered. It should be in ascending at first look and then can change by column.
$order = (isset($_GET['sortCostCode']) && strcasecmp($_GET['sortCostCode'], 'desc') == 0) ? 'DESC' : 'ASC';
$column = isset($_GET['sortcolumn']) ? $_GET['sortcolumn'] : 'logid';
$column = isset($_GET['sortcolumn']) ? $_GET['sortcolumn'] : 'prenom';
$query = "SELECT * FROM `Humeur_log` ORDER BY `$column` $order LIMIT 0,30";
$result = mysql_query($query) or die(mysql_error());;
?>
<table>
<tr>
<th><a href='?sortcolumn=logid&sortCostCode=<?php echo $order == 'DESC' ? 'ASC' : 'DESC'; ?>'>Logid</a></th>
<th><a href='?sortcolumn=prenom&sortCostCode=<?php echo $order == 'DESC' ? 'ASC' : 'DESC'; ?>'>Prenom</a></th>
</tr>
<?php
while($rows=mysql_fetch_assoc($result))
{
echo "<tr>";
echo "<td>" . $rows['logid'] . "</td>";
echo "<td>" . $rows['prenom'] . "</td>";
echo "</tr>";
}
?>
</table>