A typical phpmysql paging program. A classic phpmysql paging program this article provides a php paging code, which is a relatively simple and common limit incoming paging function. It also provides the conditional query paging function. This article provides a php paging code by using a classic php mysql paging program. this is a relatively simple and common limit incoming paging, it also provides the conditional query paging function.
A paging program for the mysql tutorial of a classic php Tutorial
This article provides a php paging code, which is a simple and common limit incoming paging code. It also provides the conditional query paging function.
*/
$ Conn = mysql_connect ($ mysql_host, $ mysql_user, $ mysql_password) or die ('server connection error ');
Mysql_select_db ($ mysql_db) or die ("selecting database tutorial errors ");
Mysql_query ("set names 'gbk '");
Function table ($ t)
{
Global $ mysql_table_prefix;
Return $ mysql_table_prefix. $ t;
}
$ SQL = "select * from". table ('keyword'). "where 1 = 1 ";
$ Sql2 = "select count (*) from". table ('keyword'). "where 1 = 1 ";
$ Py = trim ($ _ request ['py']);
If ($ act = "search" and! Empty ($ _ post ['S1'])
{
$ S1 = trim ($ _ post ['S1']); // retrieves search words
$ SQL. = "and (k1 = '$ S1' or k2 =' $ S1 ')";
$ Sql2. = "and (k1 = '$ S1' or k2 =' $ S1 ')";
}
Elseif (! Empty ($ py ))
{
$ SQL. = "and pinyin = '$ PY '";
$ Sql2. = "and pinyin = '$ PY '";
}
$ SQL. = "order by pinyin ";
$ Rscount = mysql_query ($ sql2 );
$ Rscount = @ mysql_fetch_array ($ rscount );
$ Rscount = $ rscount [0]; // obtain the total number of records
$ Page = trim ($ _ get ['Page']); // The current page number.
$ Pagesize = 30; // number of records per page
$ Pagecount = ceil ($ rscount/$ pagesize); // obtain the total number of pages
$ Pageurl = "";
If ($ page <= 1)
{
$ Page = 1;
$ Pageurl. = "homepage previous page ";
} Else
{
$ Pageurl. = "homepage previous page ";
}
If ($ page> = $ pagecount)
{
$ Page = $ pagecount;
$ Pageurl. = "Last page of the next page ";
} Else
{
$ Pageurl. = "Last page of the next page ";
}
$ Start_rs = ($ page-1) * $ pagesize; // start
$ End_rs = $ page * $ pagesize; // end
$ SQL. = "limit {$ start_rs}, {$ end_rs }";
$ Res = mysql_query ($ SQL );
?>
Mysql paging program this article provides a php paging code, which is a simple and common limit incoming paging function. It also provides the conditional query paging function. A sutra...