Ajax +php No Refresh page code (_php) tutorial

Source: Internet
Author: User
Tags mysql tutorial
Ajax +php No Refresh page code we are here to use PHP+JS+AJAX implementation of data without refreshing page code OH.

Ajax +php Tutorial No Refresh paging code
We are here to use php+ web effects +ajax Implementation of data without refreshing page code OH.
*/

index.php file
Header ("content-type:text/html; Charset=utf-8 ");
Error_reporting (E_all^e_notice);
Include (' pagination_class.php ');
MySQL tutorial _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;


?>


Pagination.js file

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

http://www.bkjia.com/PHPjc/630203.html www.bkjia.com true http://www.bkjia.com/PHPjc/630203.html techarticle Ajax +php No Refresh page code we are here to use PHP+JS+AJAX implementation of data without refreshing page code OH. Ajax +php Tutorial No Refresh page code we are here to use php+ web effects +ajax real ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.