Hi I've managed to sort a table by column when each is clicked. This is my table:
<table class="table table-hover">
<thead>
<tr>
<th><a href="?sort=id">Game ID </a></th>
<th><a href="?sort=title">Game title </a></th>
<th><a href="?sort=developer">Developers </a></th>
<th><a href="?sort=release">Year of release </a></th>
<th><a href="?sort=stock">No. of items in stock </a></th>
<th><a href="?sort=price">Cost price </a></th>
<th>Options</th>
</tr>
</thead>
I then use this to order the table according to the column selected.
if (isset($_GET['sort'])){
$sort = $_GET['sort'];
$query = "SELECT * FROM Games ORDER BY " . $sort . ";";
$result = mysqli_query($connection, $query);
(Underneath this code I use a loop to insert data into the table)
All works perfectly apart from my 'Year of release' column, when I click this the table empties.
I have no idea why this is happening.