代码拉取完成,页面将自动刷新
<?php
require_once 'common.php';
require_once 'page/page.class.php';
//获取分类信息
$sql = "SELECT `id`,`catname`,`child` FROM `news_category` WHERE `id` = $get_catid";
$mydb->query($sql);
$cat_arr = $mydb->fetch_array();
//获取当前分类下的所有子分类
$child_cat_arr = array();
$need_catid_str = '';
if($cat_arr['child']){//有子类
$sql = "SELECT `id`,`catname` FROM `news_category` WHERE `parentid` = $get_catid";
$mydb->query($sql);
$rs = '';
while($rs = $mydb->fetch_array()){
$child_cat_arr[] = $rs;
$need_catid_str .= $rs['id'].',';
}
}else{
$child_cat_arr[] = $cat_arr;
$need_catid_str .= $cat_arr['id'].',';
}
$need_catid_str = rtrim($need_catid_str, ',');
//获取分类列表信息
$showrow = 18; //一页显示的行数
$page = isset($_GET['page']) ? intval($_GET['page']) : 1;
$curpage = $page > 1 ? $page : 1;
$get_data = $_GET;
unset($get_data['page']);
$query_string = http_build_query($get_data);
$canshu = '&'.$query_string;
$url = "?page={page}".$canshu; //分页地址,如果有检索条件 ="?page={page}&q=".$_GET['q']
$sql = "SELECT `id`,`catid`,`title`,`publish_time` FROM `news_article` WHERE `catid` IN ($need_catid_str) AND `status` = 1 ORDER BY id DESC";
$total = $mydb->num_rows($sql);//记录总条数
if (!empty($page) && $total != 0 && $curpage > ceil($total / $showrow))
$curpage = ceil($total_rows / $showrow); //当前页数大于最后页数,取最后一页
//获取数据
$sql .= " LIMIT " . ($curpage - 1) * $showrow . ",$showrow;";
$mydb->query($sql);
?>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title><?php echo $cat_arr['catname'];?></title>
<link rel="stylesheet" type="text/css" href="css/font-awesome.min.css">
<link rel="stylesheet" type="text/css" href="owlcarousel/owl.carousel.css">
<link rel="stylesheet" type="text/css" href="owlcarousel/owl.theme.css">
<link rel="stylesheet" type="text/css" href="css/style.css">
</head>
<style>
</style>
<body>
<?php include 'head.php';?>
<div class="main clearfix">
<div class="crumb">
<span>您现在的位置:<a href="index.php">首页</a>
<?php
$count = count($crumb_nav) - 1;
for($i = $count; $i >= 0; $i--){
echo '> <a href="list.php?catid='.$crumb_nav[$i]['id'].'">'.$crumb_nav[$i]['catname'].'</a>';
}
?>
> <a>列表页</a>
</span>
</div>
<div class="list_main clearfix">
<div class="left">
<div class="menu_tit"><?php echo $menu_arr['parent']['catname'];?></div>
<ul>
<?php
if(isset($menu_arr['child']) && is_array($menu_arr['child'])){
foreach($menu_arr['child'] as $row){
?>
<li class="<?php if($get_catid == $row['id']){echo 'active';}?>"><a href="list.php?catid=<?php echo $row['id'];?>"><?php echo $row['catname'];?></a></li>
<?php
}
}else{//没有子栏目
?>
<li class="<?php if($get_catid == $menu_arr['parent']['id']){echo 'active';}?>"><a href="list.php?catid=<?php echo $menu_arr['parent']['id'];?>"><?php echo $menu_arr['parent']['catname'];?></a></li>
<?php
}
?>
</ul>
<div class="left_contact"></div>
</div>
<div class="list_right">
<div class="list_right_top">
<span class="list_right_top_tit"><?php echo $cat_arr['catname'];?></span>
</div>
<ul class="list_ul">
<?php while ($row = $mydb->fetch_array()) { ?>
<li><a href="detail.php?catid=<?php echo $row['catid'];?>&id=<?php echo $row['id'];?>" title="<?php echo $row['title'];?>"><?php echo mb_substr($row['title'], 0, 50, 'UTF-8');?></a><span class="date">[<?php echo date('Y-m-d', $row['publish_time']);?>]</span></li>
<?php } ?>
<?php
// if($list_arr && is_array($list_arr)):
// foreach($list_arr as $row):
// ?>
<!--<li><a href="detail.php?catid=<?php echo $row['catid'];?>&id=<?php echo $row['id'];?>" title="<?php echo $row['title'];?>"><?php echo mb_substr($row['title'], 0, 50, 'UTF-8');?></a><span class="date">[<?php echo date('Y-m-d', $row['publish_time']);?>]</span></li>-->
<?php
// endforeach;
// endif;
?>
</ul>
<!--<div class="page" style="display: none;">
<span class="total">200条</span>
<a href="">上一页</a>
<a href="">1</a>
<a href="">2</a>
<a href="">3</a>
<a href="">4</a>
<a href="">下一页</a>
<span>共15页</span>
<span class="gopage">到<input type="text" value="">页</span>
<a href="javascript:;">确定</a>
</div>-->
<div class="showPage">
<?php
if ($total > $showrow) {//总记录数大于每页显示数,显示分页
$page = new page($total, $showrow, $curpage, $url, 2);
echo $page->myde_write();
}
?>
</div>
</div>
</div>
</div>
<?php include 'foot.php';?>
<script type="text/javascript" src="js/jquery-1.11.0.min.js"></script>
<script type="text/javascript" src="js/common.js"></script>
<script type="text/javascript" src="owlcarousel/owl.carousel.js"></script>
<script>
$(function(){
$("#focus-img").owlCarousel({
autoPlay : 3000,
navigation : true,
slideSpeed : 300,
paginationSpeed : 400,
rewindSpeed: 10,
singleItem : true
});
});
</script>
</body>
</html>
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。