Xml + php dynamic loading and paging

Source: Internet
Author: User
Xml + php dynamic loading and paging: this is seen when you look at the comments of the Pacific network. The Pacific network uses jsp as the background language to generate xml files. then, bind the data to html. I used php to make the following source files.

-----------------Xml.htm ------------------




Xml



Script
Function jump (form)
{
If (form. pageNum. value> parseInt (pageCount. innerHTML) return false;
If (form. pageSize. value> parseInt (recordCount. innerHTML) return false;
ShopList. src = "xml. php? PageNo = "+ form. pageNum. value +" & pageSize = "+ form. pageSize. value +" & time = "+ (new Date (). getTime ();
}
Function pageCount_onpropertychange (form)
{
If (form. pageNum. value> parseInt (pageCount. innerHTML) form. pageNum. value = parseInt (pageCount. innerHTML );
If (form. pageSize. value> parseInt (recordCount. innerHTML) form. pageSize. value = parseInt (recordCount. innerHTML );
If (form. pageNum. value = 1)
{
Form. firstPage. disabled = true;
Form. previousPage. disabled = true;
}
Else
{
Form. firstPage. disabled = false;
Form. previousPage. disabled = false;
}
If (form. pageNum. value = form. pageCount. value)
{
Form. nextPage. disabled = true;
Form. lastPage. disabled = true;
}
Else
{
Form. nextPage. disabled = false;
Form. lastPage. disabled = false;
}
}
Script





















Store List
Shop name Operator Store level Shop introduction
Name Operator Level Introduction




----------------- Xml. php ------------------
// Require_once "Source/Global. php ";
Function getVars ($ get_vars, $ post_vars ){

$ I = count ($ get_vars );
$ J = count ($ post_vars );
If ($ I> 0 & $ j> 0 ){
While (list ($ key, $ val) = each ($ get_vars )){
$ Vars [$ key] = $ val;
}
While (list ($ key2, $ val2) = each ($ post_vars )){
$ Vars [$ key2] = $ val2;
}
} Elseif ($ I> 0 ){
While (list ($ key, $ val) = each ($ get_vars )){
$ Vars [$ key] = $ val;
}
} Elseif ($ j> 0 ){
While (list ($ key2, $ val2) = each ($ post_vars )){
$ Vars [$ key2] = $ val2;
}
} Else {
$ Vars = array ();
}
Return $ Vars;
}

$ Vars = getVars ($ HTTP_GET_VARS, $ HTTP_POST_VARS );

// Class shoplist_res extends iGlobal {
Class shoplist_res {
Function shoplist_res ($ vars, $ cookie ){
// $ This-> iGlobal ($ vars, $ cookie );
$ This-> outPut ($ vars, $ cookie );
}

// Function _ shoplist_res (){
// $ This-> db-> Close ();
//}
Function outPut ($ vars, $ cookie ){
/* $ StrQuery = "select count (*) as rc from". $ this-> db_c-> Db_Pre. "pshop order by id desc ";
$ This-> db-> Query ($ strQuery );
$ RecordCount = $ this-> db-> Assoc ();
$ RecordCount = $ RecordCount ['rc '];
@ $ This-> db-> freeResult ();*/
$ RecordCount = 25;
If (empty ($ vars ['pageno']) $ vars ['pageno'] = 1;
If (empty ($ vars ['pagesize']) $ vars ['pagesize'] = 10;
$ PageCount = ceil ($ RecordCount/$ vars ['pagesize']);
If ($ vars ['pagesize']> $ RecordCount) $ vars ['pagesize'] = $ RecordCount;
If ($ vars ['pageno']> $ PageCount) $ vars ['pageno'] = $ PageCount;
$ XmlStr. =" "." \ N ";
$ XmlStr. =" <商铺列表> "." \ N ";
$ XmlStr. = "\ t <翻页工具 pageno="\"".$vars['pageNo']."\"" pagesize="\"".$vars['pageSize']."\"" total="\"".$RecordCount."\"">"." \ N ";
$ XmlStr. = "\ t <页号码> ". $ Vars ['pageno']." "." \ N ";
$ XmlStr. = "\ t <页大小> ". $ Vars ['pagesize']." "." \ N ";
$ XmlStr. = "\ t <数量> ". $ RecordCount ." "." \ N ";
$ XmlStr. = "\ t <页数量> ". $ PageCount ." "." \ N ";
// $ StrQuery = "select t1. *, t2. * from ". $ this-> db_c-> Db_Pre. "pshop as t1 ,". $ this-> db_c-> Db_Pre. "shoptype as t2 where t1.typenum = t2.typenum order by id desc"
//. "Limit". ($ vars ['pageno']-1) * $ vars ['pagesize']. ",". $ vars ['pagesize'];
// Die ($ strQuery );
// $ This-> db-> Query ($ strQuery );
/* While ($ result = $ this-> db-> Assoc ()){
$ XmlStr. = "\ t". "\ n ";
$ XmlStr. = "\ t <商铺> "." \ N ";
$ XmlStr. = "\ t <名称>".$result['shopname']." "." \ N ";
$ XmlStr. = "\ t <经营人>".$result['shopmaster']." "." \ N ";
$ XmlStr. = "\ t <级别>".$result['shoptype']." "." \ N ";
$ XmlStr. = "\ t <简介>".$result['shopintro']." "." \ N ";
$ XmlStr. = "\ t <连接地址>personal_shop.php?id=".$result['id']." "." \ N ";
$ XmlStr. = "\ t "." \ N ";
}*/
$ SC = $ vars ['pageno'] * $ vars ['pagesize'];
If ($ SC> $ RecordCount) $ SC = $ RecordCount;
For ($ I = ($ vars ['pageno']-1) * $ vars ['pagesize']; $ I <$ SC; $ I ++ ){
$ XmlStr. = "\ t". "\ n ";
$ XmlStr. = "\ t <商铺> "." \ N ";
$ XmlStr. = "\ t <名称>这是名称:".$i." "." \ N ";
$ XmlStr. = "\ t <经营人>这是经营人:".$i." "." \ N ";
$ XmlStr. = "\ t <级别>这是级别:".$i." "." \ N ";
$ XmlStr. = "\ t <简介>这是简介:".$i." "." \ N ";
$ XmlStr. = "\ t <连接地址>personal_shop.php?id=".$i." "." \ N ";
$ XmlStr. = "\ t "." \ N ";
}
$ XmlStr. =" "." \ N ";
Header ("Content-type: text/xml \ n ");
Echo $ xmlStr;
}
}

$ Shoplist = new shoplist_res ($ vars, $ HTTP_COOKIE_VARS );
// $ Shoplist-> _ shoplist_res ();
Unset ($ sthoplist );
?>


The above php commented on the data obtained by connecting to the database. since it was put up for testing and there was no database connection, I changed it. I am not familiar with xml in many places. A smile ......

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.