首页  >  文章  >  后端开发  >  ajax实现无刷新分页(php)_PHP教程

ajax实现无刷新分页(php)_PHP教程

WBOY
WBOY原创
2016-07-21 15:35:16819浏览

复制代码 代码如下:




投票结果





用户留言如下:








复制代码 代码如下:

$link = mysql_connect('localhost', 'root', '') or die(mysql_error());
mysql_select_db('vote', $link) or die(mysql_error());
mysql_query("set names utf8");
$num = 3;
$url = "page.php";
$con = "
    ";
    $page = (isset($_REQUEST['page'])) ? $_REQUEST['page'] : 1;
    $offset = ($page - 1) * $num;
    $result = mysql_query("SELECT COUNT(*) FROM client");
    $total = mysql_fetch_row($result);
    $total = $total[0];
    $pagenum = ceil($total / $num);
    $page = min($pagenum, $page); //获得首页
    $prepg = $page - 1; //上一页
    if ($prepg $prepg = 1;
    $nextpg = ($page == $pagenum ? 1 : $page + 1); //下一页
    //如果只有一页则跳出函数:
    if ($pagenum return false;
    $sql = "SELECT `name`,`content` FROM `client` LIMIT " . $offset . "," . $num;
    $res = mysql_query($sql);
    while ($content = mysql_fetch_row($res)) {
    $con .= "
  • $content[0]:  $content[1]
  • ";
    }
    $con .= "
";
$con .=

首页|上一页||尾页


PAGE;
echo $con;
?>

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/322244.htmlTechArticle复制代码 代码如下: !DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd" html head title投票结果/title meta http-equiv="c...
声明:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn