Publish one of the strongest PHP General page classes

Source: Internet
Author: User

If you have studied ASP.net, you must have known it had a DataList in it. The paging function is very powerful, this class simulates a part of this function, I dare to use "strong" to define it, because as a General page class, this class is really "universal".
Talk less, and immediately introduce how it is used.
1. First create a new table for testing
CREATE TABLE ' Test ' (
' AA ' INT not NULL auto_increment PRIMARY KEY,
' BB ' VARCHAR not NULL,
' CC ' VARCHAR not NULL,
' TT ' INT DEFAULT ' 0 ' not NULL
);
2, the production of a template file, save as: test.htm
{Dede:page pagesize=15/}
<table width= ' 100% ' border= ' 0 ' cellpadding= ' 1 ' cellspacing= ' 1 ' bgcolor= ' #CCCCCC ' >
<tr bgcolor= ' #F8FFEE ' align= ' center ' >
&LT;TD width= ' 10% ' >aa</td>
&LT;TD width= ' 30% ' >bb</td>
&LT;TD width= ' 30% ' >cc</td>
&LT;TD width= ' 30% ' >tt</td>
</tr>
{Dede:datalist}
<tr bgcolor= ' #FFFFFF ' align= ' center ' >
<td>[field:aa/]</td>
<td>[field:bb/]</td>
<td>[field:cc/]</td>
<td>[field:tt function= ' Date ("y-m-d h-i-s", "@me") '/]</td>
</tr>
{/dede}
<tr bgcolor= ' #F8FFEE ' >
&LT;TD colspan= ' 4 ' >
{Dede:pagelist listsize=3/}
</td>
</tr>
</table>
3, write the code that calls this class
Database connection information is config_base.php this file is set
showtable.php
?
Require ("inc_datalist.php");
$dlist = new DataList ();
$dlist->init ();
$dlist->settemplet ("./test.htm");
$dlist->setsource ("SELECT * from TTT");
$liststring = $dlist->display ();

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.