![]() |
|
首页 │ Apache │ Linux│ Java│ MySQL│ 注册│帮助 | |||
[php]
<?php
//俺的翻页 不灵了,比如:显示-> 1 2 3 4 上一页 下一页,点的时候 不翻页,大家帮俺看一下 忙晕了,看不出哪里有错呀 和自己以前写的对比,也没看出来哪里有
//错 以前写的都没问题,今天的就出问题了,大家 帮俺找下错
// function build_result_footer($count, $p, $ele_per_page, $show_pages, $url)
// count:记录数,p:当前页,ele_per_page:一页记录数,show_pages:显示链接的页数,$url:链接
…………………………………………
$smarty = new MySmarty();
$p = isset($_REQUEST['p']) && intval($_REQUEST['p'])>0 ? intval($_REQUEST['p']) : 1;
$query = $SDB->query('SELECT count(pic_id) FROM `jiuzhou`');
$result = $SDB->fetch_array($query);
$count = $result[0];
if ($count>0)
{
$p = ceil($count/9) >= $p ? $p : ceil($count/9);
}
else
{
$p = 1;
}
$start = ($p-1) * 9;
$result_pages = build_result_footer($count, $p, 9, 2, 'parties/jiuzhou/index.php');
$smarty->assign('result_pages',$result_pages);
if($count > 0)
{
$start = ($p - 1) * 9;
$str_sql = 'SELECT pic_title, pic_url
FROM `jiuzhou`
ORDER BY pic_id
LIMIT ' . $start . ', 9';
$query = $SDB->query($str_sql);
$i = 0;
while ($result = $SDB->fetch_array($query))
{
$unit_array[$i] = array("unit_pic" => $result['pic_url'],"unit_title" => $result['pic_title']);
$i++;
}
$smarty->assign("unit_array", $unit_array);
}
$SDB->close_database();
if (is_object($MDB))
{
$MDB->close_database();
}
$smarty->assign('site_name', SITE_NAME);
$smarty->assign('img_base_url',$img_base_url);
$smarty->display('index.html');
…………………………………………………………
?>
[/php]


[ 本帖最后由 1128sky7 于 2006-12-20 03:11 PM 编辑 ]

