Change the page class of the moderator to a php Tutorial that supports php4.

Source: Internet
Author: User
Before changing the page class of the moderator to support php4, the moderator's class is used for paging ~~~ However, one of the most recent servers is the php4 version ~~ I checked the information ~ Php4 does not support public, static, and so on ~~~ So please advise me ~ Change the following paging class to support php4

Ps: constant ("page_size") is a constant defined in the config file.

 1, 'prve' => $ page> 1? $ Page-1: 1, 'next' => $ page <$ count? $ Page + 1: $ count, 'end' => $ count,); foreach ($ d as $ k => $ v) {$ _ GET ['Page'] = $ v; $ tpl = str_replace ($ k, http_build_query ($ _ GET), $ tpl);} return $ tpl. "Current number ". $ page. "page | total ". $ count. "page";}/* put $ SQL = "..... "; $ rs = mysql_query ($ SQL); or $ rs = mysql_query (" select .... "); to include 'Paging. php '; $ rs = paging: prepare ($ SQL, number of lines per page); write paging: bar () where pagination entries need to appear (); you can. */?>


Reply to discussion (solution)

Php 4.3.4
I don't know your version. if you have any questions

Class paging {// add a method for passing data between statically called methods function para ($ na) {static $ ar; if (func_num_args () = 1) return $ ar [$ na]; $ ar [$ na] = func_get_arg (1);} function prepare ($ SQL, $ pagesize = '') {$ pagesize = constant ("page_size"); $ page = isset ($ _ GET ['Page'])? $ _ GET ['Page']: 1; $ pageon = ($ page-1) * $ pagesize; $ SQL = preg_replace ('/select \ s/I ', '$ 0SQL_CALC_FOUND_ROWS', $ SQL ). "limit $ pageon, $ pagesize"; $ rs = mysql_query ($ SQL); $ p = mysql_query ('select FOUND_ROWS () '); list ($ count) = mysql_fetch_row ($ p); paging: para ('count', $ count); paging: para ('size', $ pagesize); paging :: para ('page', $ page); return $ rs;} function bar ($ tpl = '') {if (! $ Tpl) $ tpl = 'Last page of the previous homepage '; $ count = ceil (paging: para ('count')/constant ("page_size ")); $ page = paging: para ('page'); unset ($ _ GET ['Page']); $ d = array ('reset' => 1, 'prve' => $ page> 1? $ Page-1: 1, 'next' => $ page <$ count? $ Page + 1: $ count, 'end' => $ count,); foreach ($ d as $ k => $ v) {$ _ GET ['Page'] = $ v; $ tpl = str_replace ($ k, http_build_query ($ _ GET), $ tpl);} return $ tpl. "Current number ". $ page. "page | total ". $ count. "page" ;}}// php4 does not have the http_build_query function, so you need to define an if (! Function_exists ('http _ build_query '): function http_build_query ($ formdata, $ numeric_prefix = '', $ mode = 0) {static $ ar = array (); foreach ($ formdata as $ k =>$ v) {if (is_array ($ v) {if ($ mode ++) http_build_query ($ v, $ numeric_prefix. '['. $ k. ']'); else http_build_query ($ v, $ k);} else {if ($ mode) $ ar [] = $ numeric_prefix. '['. $ k. '] = '. urlencode ($ v); else $ ar [] = (is_numeric ($ k )? $ Numeric_prefix. $ k: $ k ). '= '. urlencode ($ v) ;}}if (-- $ mode <0) {$ r = join ('&', $ ar); $ ar = array (); return $ r;} return '';} endif;

Php 4.3.4
I don't know your version. Is there a problem with PHP code? 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 class paging {// add a method for static calls ......

Now this machine does not have FTP, so I will test it after going back ~~ Another question to ask is that when smarty is used as the background, frameset is used, and the result page is blank, baidu has checked the path and encoding after the solution (see this article http://blog.csdn.net/wxlhlh001/article/details/7049938 )..... The result is displayed on a blank page, which is OK. For example, if you enter header. php, menu. php, and main. php in the address bar, they can be normally displayed .....

I don't know what problems you encounter, but I know that every Framework page has its own processing program.

I don't know what problems you encounter, but I know that every Framework page has its own processing program.

Paste some code ~

The root directory contains:
Index. php
Top. php
Menu. php
Main. php

The root directory contains the templates folder.
The templates folder contains:
Index.html
Top.html
Menu.html
Main.html

Index. php

 display("index.html");?>


Top. php
 get_name();$smarty->assign("name",$name);$smarty->display("top.html");?>


Menu. php
 display("menu.html");?>


Main. php
 display("main.html");?>



Index.html
 Background management-Red Theory Research Institute              
 
  
&lt;Body&gt; &lt;/body&gt;
 

Http: // localhost/admin/menu. php
Http: // localhost/admin/top. php

These can be properly displayed

Http: // localhost/admin/index. php
Page blank

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.