首页 > 作文

ajax实现无刷新分页(php)

更新时间:2023-04-06 13:27:23 阅读: 评论:0

复制代码 代码如下:

<!doctype html public “-//w3c//dtd html 4.01 transitional//en” “/d/file/titlepic/loo.dtd& />
<html>

<head>

<title>投票结果</title>

<meta http-equiv=”content-type” content=”text/html; chart=utf-8″ />

<script type=”text/javascript”>

function getxmlhttpobject()

{

var xmlhttp=null;

try

{

// firefox, opera 8.0+, safari

xmlhttp=new xmlhttpreq9月10日是什么日子uest();

}

catch (e)

{

// internet explorer

try

{

xmlhttp=new activexobject(“msxml2.xmlhttp”);

}

catch (e)报社招聘

{

xmlhttp=new activexobject(“microsoft.xmlhttp”);

}

}

return xmlhttp;

}

function checkajax(){

xmlhttp=getxmlhttpobject()

if (xmlhttp==null)

{

alert (“您的浏览器不支持ajax!”);

return ;

}el

{

return xmlhttp;

}

}

function preshow(){

ajaxobj = checkajax();

var url = “page.php?page=1”;

ajaxobj.onreadystatechange=statechanged;

成语积累ajaxobj.open(“get”,url,true);

ajaxobj.nd(null);

}

function showhint1(str)

{

ajaxobj = checkajax();

document.getelementbyid(“msg”).innerhtml=”正在读取数据……”;

var url = str;

ajaxobj.onreadystatechange=statechanged;

ajaxobj.open(“get”,url,true);

ajaxobj.nd(null);

}

function showhint2(str)

{

ajaxobj=checkajax();

document.getelementbyid(“msg”).innerhtml=”正在读取数据……”;

var url = str;

ajaxobj.onreadystatechange=statechanged;

ajaxobj.open(“get”,url,true);

ajaxobj.nd(null);

}

function showhint3(str)

{

ajaxobj=checkajax();

document.getelementbyid(“msg”).innerhtml=”正在读取数据……”;

var url = str;

ajaxobj.onreadystatechange=statechanged;

ajaxobj.open(“get”,url,true);

ajaxobj.nd(null);

}

function showhint4(str)

{document.getelementbyid(“msg”).style.display=”none”;

ajaxobj=checkajax();

document.getelementbyid(“msg”).innerhtml=”正在读取数据……”;

var url = str;

ajaxobj.onreadystatechange=statechanged;

ajaxobj.open(“get”,url,true);

ajaxobj.nd(null);

}

function statechanged()

{

if (xmlhttp.readystate==4)

{

document.getelementbyid(“message”).innerhtml=xmlhttp.respontext;

}

}

</script>

</head>

<body onload=”preshow()”>

<div id=”wrapper”>

<h4>用户留言如下:</h4>

<div id=”message”>

</div>

</div>

</body>

</html>

复制代码 代码如下:
南京工业大学怎么样
<?php

$link = mysql_connect(‘localhost’, ‘root’, ”) or die(mysql_error());

mysql_lect_db(‘vote’, $link) or die(mysql_error());

mysql_query(“t names utf8”);

$num = 3;

$url = “page.php”;

$con = “<ul id=’msg’>”;

$page = (ist($_request[‘page’])) ? $_request[‘page’] : 1;

$offt = ($page – 1) * $num;

$result = mysql_query(“lect count(*) from client”);

$total = mysql_fetch_row($result);

$total = $total[0];

$pagenum = ceil($total / 数不胜数的近义词$num);

$page = min($pagenum, $page); //获得首页

$prepg = $page – 1; //上一页

if ($prepg <= 1)

$prepg = 1;

$nextpg = ($page == $pagenum ? 1 : $page + 1); //下一页

//如果只有一页则跳出函数:

if ($pagenum <= 1)

return fal;

$sql = “lect `name`,`content` from `client` limit ” . $offt . “,” . $num;

$res = mysql_query($sql);

while ($content = mysql_fetch_row($res)) {

$con .= “<li><span>$content[0]:</span>$content[1]</li>”;

}

$con .= “</ul>”;

$con .= <<< page

<p id=”page”><a href=”#” id=”first” onclick=”showhint1(‘$url?page=1’)”>首页</a>|<a href=”#” id=”pre” onclick=”showhint2(‘$url?page=$prepg’)”>上一页</a>|<a href=”#” id=”next” onclick=”showhint3(‘$url?page=$nextpg’)”>下一页</a>|<a href=”#” id=”last” onclick=”showhint4(‘$url?page=$pagenum’)”>尾页</a></p>

page;

echo $con;

?>

本文发布于:2023-04-06 13:27:19,感谢您对本站的认可!

本文链接:https://www.wtabcd.cn/fanwen/zuowen/f7cb355e23acf2cd887bb6259b388742.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

本文word下载地址:ajax实现无刷新分页(php).doc

本文 PDF 下载地址:ajax实现无刷新分页(php).pdf

标签:代码   数据   下一页   上一页
相关文章
留言与评论(共有 0 条评论)
   
验证码:
Copyright ©2019-2022 Comsenz Inc.Powered by © 专利检索| 网站地图