Home > Backend Development > PHP Tutorial > ajax +php no refresh paging code (1/2)_PHP tutorial

ajax +php no refresh paging code (1/2)_PHP tutorial

WBOY
Release: 2016-07-13 17:07:35
Original
804 people have browsed it

ajax +php无刷新分页代码 我们这里是利用php+js+ajax实现数据无刷新分页代码哦。

ajax +php教程无刷新分页代码
我们这里是利用php+网页特效+ajax实现数据无刷新分页代码哦。
*/

//index.php文件
header("content-type: text/html; charset=utf-8");
error_reporting(e_all^e_notice);
include('pagination_class.php');
mysql教程_connect('localhost', 'root', '') or die(mysql_error());
mysql_select_db('mydemo');
mysql_query("set names 'utf8'");
?>


$qry = "select * from students";
$searchtext = "";
if($_request['search_text']!=""){
$searchtext = $_request['search_text'];
$qry .=" where name like '$searchtext%'";
}
//for pagination
$starting=0;
$recpage = 2;//number of records per page

$obj = new pagination_class($qry,$starting,$recpage);
$result = $obj->result;

   
   ?>


   
   
   
    
   
   
  

    search
     
    

   
   

    
    
     $counter = $starting + 1;
while($data = mysql_fetch_array($result)) {?>
      
      
      
       $counter ++;
} ?>
    
      
     
     
    
     
    
    
    
sl noname
anchors; ?>
total; ?>
no data found

   

   

   


 pagination.js文件
   

      function $()
{
  var elements = new array();
  for (var i = 0; i < arguments.length; i++)
  {
    var element = arguments[i];
    if (typeof element == 'string')
      element = document.getelementbyid(element);
    if (arguments.length == 1)
      return element;
    elements.push(element);
  }
  return elements;
}

var xmlhttp
function pagination(page)
{
xmlhttp=getxmlhttpobject();
if (xmlhttp==null)
  {
  alert ("your browser does not support ajax!");
  return;
  }
var url="test_sub.php";
url = url+"?starting="+page;
url = url+"&search_text="+$('search_text').value;
url=url+"&sid="+math.random();
xmlhttp.onreadystatechange=statechanged;
xmlhttp.open("get",url,true);
xmlhttp.send(null);
}

function statechanged()
{
if (xmlhttp.readystate==4)
{
$("page_contents").innerhtml=xmlhttp.responsetext;
}
}

function getxmlhttpobject()
{
var xmlhttp=null;
try
  {
  // firefox, opera 8.0+, safari
  xmlhttp=new xmlhttprequest();
  }
catch (e)
  {
  // internet explorer
  try
    {
    xmlhttp=new activexobject("msxml2.xmlhttp");
    }
  catch (e)
    {
    xmlhttp=new activexobject("microsoft.xmlhttp");
    }
  }
return xmlhttp;
}

1 2

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/630203.htmlTechArticleajax +php无刷新分页代码我们这里是利用php+js+ajax实现数据无刷新分页代码哦。 ajax +php教程无刷新分页代码 我们这里是利用php+网页特效+ajax实...
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template