Home > Backend Development > PHP Tutorial > ajax实现无刷新分页(php)_php实例

ajax实现无刷新分页(php)_php实例

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-07 17:25:55
Original
898 people have browsed it
复制代码 代码如下:




投票结果





用户留言如下:








复制代码 代码如下:

$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;
?>
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
angular.js - Angularjs $http ajax issue?
From 1970-01-01 08:00:00
0
0
0
Ajax click submit but no response!
From 1970-01-01 08:00:00
0
0
0
javascript - Questions about ajax asynchronous
From 1970-01-01 08:00:00
0
0
0
javascript - Questions about ajax?
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template