include_once ('header.htm');?>
//分页的函数
function news($pageNum = 1, $pageSize = 3)
{
$array = array();
$con = mysqli_connect("sql208.ccccocccc.cc","vh0_36240789","s19750825","vh0_36240789_1");
mysqli_select_db($con, "vh0_36240789_1");
mysqli_set_charset($con, "utf8");
// limit为约束显示多少条信息,后面有两个参数,第一个为从第几个开始,第二个为长度
$rs = "select * from sx order by sxid desc limit " . (($pageNum - 1) * $pageSize) . "," . $pageSize;
$r = mysqli_query($con, $rs);
while ($obj = mysqli_fetch_object($r)) {
$array[] = $obj;
}
mysqli_free_result($r);
return $array;
}
//显示总页数的函数
function allNews()
{
$con = mysqli_connect("sql208.ccccocccc.cc","vh0_36240789","s19750825","vh0_36240789_1");
mysqli_select_db($con, "vh0_36240789_1");
mysqli_set_charset($con, "utf8");
$rs = "select count(*) num from sx"; //可以显示出总页数
$r = mysqli_query($con, $rs);
$obj = mysqli_fetch_object($r);
/*mysqli_close($con,"vh0_36240789_1");*/
return $obj->num;
}
@$allNum = allNews();
@$pageSize = 6; //约定每页显示几条信息
@$pageNum = empty($_GET["pageNum"])?1:$_GET["pageNum"];
@$endPage = ceil($allNum/$pageSize); //总页数
@$array = news($pageNum,$pageSize);
echo
'
';
foreach($array as $key=>$values){
echo
'
姓名:'.$values->sxname.' |
来自:'.$values->sxaddress.' |
诚心祈祷: |
'.$values->hxgd.'
|
时间:'.date("Y-m-d",$values->sxshijian).'
|
|
|
|
'.$values->sxname.' |
|
';}
?>
include_once ('footer.htm');?>
mysqli_close($con,"vh0_36240789_1"); ?>