我刚刚为一家旅游公司创建了一个分页功能。有两件事我想改变,我无法弄明白。
if (date($row['date']) getdate()) { // echo trip info here }
-2。在列表中的每次旅行之后,有一个分隔符(是正确的单词吗?)来分隔每个旅行的信息。在最后一次旅行,如果页面我不想要那个分隔符。我不知道如何做到这一点:/
提前感谢任何帮助&建议。
<?php
if (isset($_GET["p"])) { $page = $_GET["p"]; } else { $page=1; };
$start_from = ($page-1) * 4;
$sql = "SELECT * FROM destinations ORDER BY date ASC LIMIT $start_from, 4";
$result = mysqli_query ($con,$sql);
while($row = mysqli_fetch_array($result))
{
echo "<div class='row'>";
echo "<div class='col-md-4 col-sm-4'>";
echo "<img src='" . $row ['img'] . "' alt='' class='img-responsive'>";
echo "</div>";
echo "<div class='col-md-8 col-sm-8'>";
echo "<h2><a href='" . $row ['url'] . "'>" . $row ['name'] . "</a></h2>";
echo "<ul class='blog-info'>";
echo "<li><i class='icon-calendar'></i> " . date("d/m/y", strtotime($row['date'])) . "</li>";
echo "</ul>";
echo $row ['description'];
echo "<a class='btn theme-btn' href='" . $row ['url'] . "'>View Details <i class='icon-angle-right'></i></a>";
echo "</div>";
echo "</div>";
echo "<hr class='blog-post-sep'>";
}
$sql = "SELECT COUNT(trip_id) FROM destinations";
$result = mysqli_query($con,$sql);
$row = mysqli_fetch_row($result);
$total_records = $row[0];
$total_pages = ceil($total_records / 4);
echo "<div class='text-center'> <ul class='pagination pagination-centered'>";
for ($i=1; $i<=$total_pages; $i++) {
echo "<li><a href='routea.php?p=".$i."'>".$i."</a></li>";
};
echo "</ul></div>";
mysqli_close($ CON); ?&GT;
答案 0 :(得分:1)
更改SQL以过滤掉不需要的行程:
SELECT * FROM destinations
WHERE date < CURRENT_DATE()
ORDER BY date ASC
LIMIT $start_from, 4
您可以使用CSS解决它:
hr.blog-post-sep:last-of-type {
display: none;
}