【发布时间】:2016-11-29 06:46:36
【问题描述】:
我目前正在开发一个活动日历,它允许用户在日期和地点和日期和地点之间进行排序。
这是我用于订单的代码:
$order = isset($_GET['sort'])?$_GET['sort']:'date_added';
$result = mysqli_query($con,"SELECT * FROM calendar ORDER BY $order");
$sql = mysql_query($query);
现在,当您单击按钮时,它会设置将用于这样排序的变量
onclick="location.href=' index.php?sort=date&place'"
现在这很好用,但是当我启动我的活动日历时,它是空白的...如何为我的日历设置默认顺序?
这是日历输出的代码:
echo "<table class='table table-striped' >
<thead>
<tr>
<th>Artist</th>
<th>Place</th>
<th>Date</th>
<th>Genre</th>
</tr>
</thead>";
while($row = mysqli_fetch_array($result))
{
$date = $row['date'];
$convdate = date('d-m-Y', strtotime($row['date']));
echo "<tr>";
echo "<td>" . $row['artist'] . "</td>";
echo "<td>" . $row['place'] . "</td>";
echo "<td>" . $convdate . "</td>";
echo "<td>" . $row['genre'] . "</td>";
echo "</tr>";
}
echo "</table>";
mysqli_close($con);
?>
【问题讨论】:
-
你为什么混合
mysqli_*和mysql_*?$query呢?
标签: php mysqli html-table