<?php
require_once("configs.php");
$sql="select * from product";
$rs=$mysqli->query($sql);
$count=$rs->num_rows;
$num=4;
$pagecount=ceil($count/$num);
if(@$_GET['page']==""||$_GET['page']<1){
$page=1;
}
else{
$page=$_GET['page'];
if($page>$pagecount){
$page=$pagecount;
}
}
$start=($page-1)*$num;
$sql=$sql." limit $start,$num";
$rs1=$mysqli->query($sql);
while($a=$rs1->fetch_array()){
$aaa[]=$a;
}
$smarty->assign('aaa',$aaa);
$smarty->assign('page',$page);
$smarty->assign('pagecount',$pagecount);
$smarty->display("a.html");
?>
configs.php
<?php
require_once("./libs/Smarty.class.php");
$smarty= new smarty();
$smarty->template_dir="templates";
$smarty->config_dir="configs";
$smarty->compile_dir="templates_c";
$mysqli=new mysqli("localhost","root","","product");
$mysqli->query("set names utf8");
?>