在我的网页中,数据库中的数据正在动态显示。这些数据除以年份。我想添加显示年份的动态按钮,如果按下该按钮,则仅显示那些年份的内容。
我的代码:
<?php
$c_year = date('Y');
$s_year = 1988;
$t_year = $c_year - $s_year;
do {
$query = "SELECT * FROM `press_release` WHERE year(date) LIKE '$c_year' AND del_status=0";
$press_news = $conn->query($query);
$press_rows = $press_news->num_rows;
if ($press_rows > 0) {
?>
<a href="<?php echo $row['page_link']; ?>">
<h2 class="title searchh3"><?php echo $c_year ?></h2>
</a>
<?php }
?>
<?php while ($row = mysqli_fetch_array($press_news)) {
?>
<div class="col-lg-12 col-md-12 col-sm-12" style="padding: 2% 0">
<a href="press_details.php?id=<?php echo $row['id'] ?>">
<h3 class="searchh3" style="color: #EB2227;"><?php echo $row['title']; ?></h3>
</a>
<h5 class="searchh3" style="color: #EB2227;"><?php echo $row['date']; ?></h5>
<p><?php echo substr($row['description'], 0, 300); ?>...</p>
</div>
<?php
}
$c_year--;
} while ($c_year > $s_year);
?>