xml+php dynamic load and paging _php tutorial

Source: Internet
Author: User
Tags cdata vars
This is seen in the comments of the Pacific NET, the Pacific net is used as a background language JSP, used to generate XML files. Then you bind the data to the HTML. I just used PHP to do one of the following is the source file.

-----------------xml.htm------------------




Xml
























Shop List
Shop Name Operators Shop level Shop Introduction
Name Business person Level Brief 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 ($key 2, $val 2) = each ($post _vars)) {
$Vars [$key 2] = $val 2;
}
} elseif ($i > 0) {
while (list ($key, $val) = each ($get _vars)) {
$Vars [$key] = $val;
}
} elseif ($j > 0) {
while (List ($key 2, $val 2) = each ($post _vars)) {
$Vars [$key 2] = $val 2;
}
} 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."\""> <翻页工具 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\t <名称> ".$result['shopname']." ". " \ n ";
$xmlStr. = "\t\t <经营人> ".$result['shopmaster']." ". " \ n ";
$xmlStr. = "\t\t <级别> ".$result['shoptype']." ". " \ n ";
$xmlStr. = "\t\t <简介> ".$result['shopintro']." ". " \ n ";
$xmlStr. = "\t\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\t <名称> 这是名称:".$i." ". " \ n ";
$xmlStr. = "\t\t <经营人> 这是经营人:".$i." ". " \ n ";
$xmlStr. = "\t\t <级别> 这是级别:".$i." ". " \ n ";
$xmlStr. = "\t\t <简介> 这是简介:".$i." ". " \ n ";
$xmlStr. = "\t\t <连接地址> personal_shop.php?id=".$i." ". " \ n ";
$xmlStr. = "\ t "." \ n ";
}
$xmlStr. = " "." \ n ";
Header ("content-type:text/xml\n\n");
Echo $xmlStr;
}
}

$shoplist = new Shoplist_res ($vars, $HTTP _cookie_vars);
$shoplist->_shoplist_res ();
Unset ($sthoplist);
?>


The above PHP, the comment is I connect the database to obtain data, since put up test, there is no database connection, so changed a bit. I also just answer XML soon, many places still do not understand. Laughed at ...

http://www.bkjia.com/PHPjc/314885.html www.bkjia.com true http://www.bkjia.com/PHPjc/314885.html techarticle This is seen in the comments of the Pacific NET, the Pacific net is used as a background language JSP, used to generate XML files. Then you bind the data to the HTML. I just used PHP to do a ...

  • Related Article

    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.