您好我设法按列排序时单击每个列。 这是我的表:排序不起作用的PHP SQL排序依据
<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>
然后我用这个根据所选列排序表格。
if (isset($_GET['sort'])){
$sort = $_GET['sort'];
$query = "SELECT * FROM Games ORDER BY " . $sort . ";";
$result = mysqli_query($connection, $query);
(在此之下的代码,我用一个循环来将数据插入到表)
所有完美的作品除了我的“上市年份”栏,当我点击这个桌子清空。
我不知道为什么会发生这种情况。
如果以下答案解决了您的问题,请务必接受它,http://meta.stackexchange.com/questions/5234/how-does-accepting-an-answer-work。如果您有问题,请发帖。 – chris85
将尝试它现在裸露在我身边,在此先感谢 – Gareth