PHP + MSSQL paging source code

Source: Internet
Author: User
<? PHP
// Connect to the database
$ Myserver = "192.168.0.123"; // host
$ Myuser = "sa"; // User Name
$ Mypass = ""; // Password
$ Mydb = ""; // MSSQL database name
$ S = mssql_connect ($ myserver, $ myuser, $ mypass );
$ D = mssql_select_db ($ mydb, $ S );
// Paging information/
$ Biao = "yonghujiben ";
$ Xianshi = 30; // number of entries displayed on each page
// Open the user table. This table mainly calculates the total number of records and can be divided into several pages.
$ SQL = "select * from $ Biao ";
$ Query = mssql_query ($ SQL );
$ Zongshu = mssql_num_rows ($ query );
$ Yeshu = Ceil ($ zongshu/$ xianshi); // return the maximum integer of the current decimal number.
Echo "$ Yeshu page in total ";
If ($ page = "" or $ page> $ Yeshu or $ page <0 or $ page = 0) {$ page2 = 1 ;}
Else
{
$ Page2 = intval ($ page); // convert the page number to a number
}

// $ Page2 = intval ($ page); // convert the page number to a number

Echo $ seek = $ xianshi * ($ page2-1 );
Echo "<br> ";
Echo $ xianshi;
$ Top_shuzi = $ page2 * $ xianshi;

// User display data in this table
$ SQL _e = "select top $ top_shuzi * from $ Biao ";
$ Query_e = mssql_query ($ SQL _e );
Echo "<br> ";
Mssql_data_seek ($ query_e, $ seek );
While ($ rs = mssql_fetch_object ($ query_e ))
{
// Print_r ($ row );
Echo $ RS-> QQ;
Echo "<br> ";
}
?>

<? PHP

$ Xianshiye = 8; // displays the current page at a time.

$ I = $ xianshiye + ($ page2-1 );

If ($ I> $ Yeshu)
{$ I = $ Yeshu ;}

If ($ page2> 1)
{

$ Shangyiye = $ page2-1;
Echo "<a href = '$ php_self? Page = $ shangyiye '> previous page </a>/N ";}

If ($ page2-$ xianshiye <1 or $ page2-$ xianshiye = 0)
{
$ QQ = 1;
}
Else
{
$ QQ = $ page2-$ xianshiye;
}
For ($ Y = $ QQ; $ Y <= $ page2-1; $ y ++)
{
Echo "<a href = $ php_self? Page = $ Y> [$ y] </a>/N ";
}

For ($ Y = $ page2; $ Y <= $ I; $ y ++)
{
Echo str_replace ("<a href = $ php_self? Page = $ Y> [$ page2] </a> "," <strong> $ Y </strong> "," <a href = $ php_self? Page = $ Y> [$ y] </a>/N ");
// Echo "<a href = $ php_self? Page = $ Y> $ Y </a>/N ";
}

If ($ page2 = $ Yeshu)
{}
Else
{
$ Xiayiye = $ page2 + 1;
Echo "<a href = '$ php_self? Page = $ xiayiye '> next page </a> ";}

?>

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.