代码拉取完成,页面将自动刷新
<?php
require_once('header.php');
require_once('db_fns.php');
require_once('page.class.php');
?>
<div class="news-bg"></div>
<div class="introduction-item">
<?php
require_once('news_navbar.php');
?>
<div class="introduction-right">
<?php
$conn = db_connect();
$conn->query("set names utf8");
//分页参数
$showrow = 12; //一页显示的行数
$curpage = empty($_GET['page']) ? 1 : $_GET['page']; //当前的页,还应该处理非数字的情况
$result1 = $conn->query("select * from news where class='6'");
$total=$result1->num_rows;
if (!empty($_GET['page']) && $total != 0 && $curpage > ceil($total / $showrow))
$curpage = ceil($total / $showrow); //当前页数大于最后页数,取最后一页
//去掉当前url中的page
$url = "trends?page={page}";
$query = "select * from news where class='6' order by id desc limit " . ($curpage - 1) * $showrow . ",$showrow;";
$result = $conn->query($query);
$content = '';
if(!isset($_GET['id'])) {
$content.='<div class="introduction-right-location">当前位置:首页 > 新闻动态 > 企业公告</div><div class="introduction-right-content"><div class="news-content"><ul>';
while($row = $result->fetch_assoc()) {
$date = explode(' ',$row['date']);
$content.='<li><span class="news-title"><a href="company_news?id='.$row['id'].'">'.$row['title'].'</a></span><span class="news-time">'.$date[0].'</span></li>';
}
$content.='</ul></div></div><div class="rzpages">';
echo $content;
//显示分页
$page = new page($total, $showrow, $curpage, $url, 2);
echo $page->myde_write();
}
else {
$result = $conn->query("select * from news where id=".$_GET['id']."");
$row = $result->fetch_assoc();
$content.='<div class="introduction-right-content"><div class="news-content"><div class="introduction-rl-title">'.$row['title'].'<p>发布日期:'.$row['date'].'</p></div>'.$row['content'].'</div></div>';
echo $content;
}
?>
</div>
</div>
</div>
<script>
$(function(){
$(".news-content img").parent().addClass("news-img");
})
</script>
<?php
require_once('footer.php');
?>
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。