?? ?? ?? ??
1. ??? ??
?? ?? ????, ?? ?? ????? ?? ??? ???? ??? ?? ??????? ???? ???
? index.php ???? ?????. ??? ??? ????.
<?php header("Content-Type:text/html;charset=utf-8"); //獲取要查詢的分類ID,0表示全部 $cid=isset($_GET['cid'])?intval($_GET['cid']):0; //獲取查詢列表?xiàng)l件 $where=''; if($cid) $where="where cid=$cid"; //初始化數(shù)據(jù)庫(kù)操作類 require './init.php'; //載入分頁(yè)類 require './page.class.php'; //獲取當(dāng)前頁(yè)碼號(hào) $page=isset($_GET['page'])?intval($_GET['page']):1; //拼接查詢條件 //獲取總記錄數(shù) $sql="select count(*) as total from cms_article $where"; $results=$db->fetchRow($sql); $total=$results['total']; //實(shí)例化分頁(yè)類 $Page=new Page($total,4,$page); //Page(總記錄數(shù),每頁(yè)顯示條數(shù),當(dāng)前頁(yè)) $limit=$Page->getLimit(); //獲取分頁(yè)鏈接條件 $page_html=$Page->showPage(); //獲取分頁(yè)html鏈接 //var_dump($total);die(); //分頁(yè)獲取文章列表 $sql="select id,title,content,author,addtime,cid from cms_article $where order by addtime DESC limit $limit"; $articles=$db->fetchAll($sql); foreach ($articles as $k=>$v){ //mb_substr(內(nèi)容,開(kāi)始位置,截取長(zhǎng)度,字符集) $articles[$k]['content']=mb_substr(trim(strip_tags($v['content'])),0,150,'utf-8').'......'; } $sql="select name from cms_category ORDER BY sort"; $categories=$db->fetchAll($sql); //var_dump($categories);die(); require './indexHtml.php';
??? ??? ??? ? ??????? ?? ?? ??? ??????.
?? ?? ?????
??? ?? ??: $page_html
?? ?? ?? ??: $categories
?? ????: $ ??
? ??? ??? ?? ???? ??? ?????.
2. ??? ?? ?? ??? ??:
? indexHtml.php ???
???? ??? ?? ?????.
?? ??? ?? ??? ??:
?? ?? ??? ??:
??????? ? ?? ???? ? ???? ??? ?? ?? ???? ??? ?? ?????.