在每个列上单击,该列将执行ASC或DESC。在ASC上,我想将列图像从下向上更改为:
https://solenoidal-slate.000webhostapp.com/
在Jquery中,我假设使用SQL" Get"声明? (因为它当前可能是ASC或DESC)。
我不担心SQL Injections / PDO,因为我稍后会添加该代码。
$(".column_sort").on('click', function () {
alert("Table will now sort.")
});
if(isset($_GET['sort'])){
$sort = $_GET['sort'];
}
$sort = ($sort == 'DESC') ? 'ASC': 'DESC';
$query = "SELECT * FROM employees ORDER BY $order $sort";
$results = mysqli_query($con, $query); ?>
<th>
<a class="column_sort" id="id" href="?order=id&sort=<?php echo $sort; ?>">
ID<span id="arrow" class="glyphicon glyphicon-arrow-down"></span>
</a>
</th>