PHPMSSQL paging instance, phpmssql paging instance _ PHP Tutorial

Source: Internet
Author: User
PHPMSSQL paging instance and phpmssql paging instance. PHPMSSQL paging instance: phpmssql paging instance this article shares with you the PHPMSSQL refresh paging instance. The details are as follows: php * page description: * $ linkmssql_connect (MYSQL20 php mssql paging instance, phpmssql paging instance

The examples in this article share with you the following details about php mssql refresh paging instances:

<? Php/* 'page description: */$ link = mssql_connect ("MYSQL2005", "sa", "123456") or die ("db link error! ". Mssql_error (); mssql_select_db (" edu_dzk ", $ link) or die (" db open error! ". Mssql_error (); // mssql_query ("set names 'utf8'"); $ sqlstrcount = "SELECT count (1) FROM reguser "; $ page = $ _ GET ["page"]; if (! Is_numeric ($ page) {$ page = "1" ;}$ pagesize = "30"; // $ SQL = mysql_query ($ sqlstr ); // $ totalnum = mysql_num_rows ($ SQL); $ SQL = mssql_query ($ sqlstrcount); list ($ totalnum) = mssql_fetch_row ($ SQL ); $ pagecount = ceil ($ totalnum/$ pagesize); $ offset = ($ page-1) * $ pagesize; $ sqlstr = "Select top ". ($ pagesize ). "* from reguser where id not in (select top ". ($ page-1) * $ pagesize ). "id from reguser order by id desc) order by id desc"; $ SQL = mssql_query ($ sqlstr); $ result = ""; while ($ result = mssql_fetch_array ($ SQL) {echo $ result ["id"].'
';} Showpageinfo2 ($ totalnum, $ pagecount, $ page, "& z = ". $ z); mssql_Close ($ link); function showpageinfo2 ($ totalnum, $ pagecount, $ page, $ filster) {echo "total: $ totalnum records, total $ pagecount page, current is the $ page "; if ($ page! = 1) {echo "homepage"; echo "previous page";} if ($ page <$ pagecount) {echo "next page"; echo "last page" ;}}?>

The following is a general paging formula for PHP + MSSQL for your reference. The details are as follows:

<? Php // phpinfo (); // $ conn = mssql_connect ('2017. 168.0.3 ', 'app', 'web') or die (mssql_get_last_message (); // if ($ conn )//{//? Echo "success"; //} else {//? Echo "fail"; //}?>PHP paging<? $ GPageSize = 10; // number of records displayed on each page $ hostname = ". "; // MsSQL Server $ dbuser =" sa "; // username $ dbpasswd =" "; // password // connect to the database $ id = mssql_connect ($ hostname, $ dbuser, $ dbpasswd) or die ("unable to connect to the database server! "); $ Db = mssql_select_db (" phmis04 ", $ id) or die (" unable to connect to the database! "); // Take the xxx table as an example to construct the query string $ query =" select top 20 ag_mate, ag_color, ag_width, ag_mode, mi_name, convert (char, ag_date, 23) as ag_date, ag_grid, au_name, ag_num from acco_grid join mate_info on ag_mate = mi_id join appl_unit on au_id = ag_unit; "; // execute the query statement $ rresult = mssql_query ($ query) or die ("unable to execute SQL: $ query"); // $ page variable indicates the currently displayed page if (! Isset ($ page) $ page = 1; if ($ page = 0) $ page = 1; // Obtain the number of records currently queried $ nNumRowsif ($ nNumRows = mssql_num_rows ($ rresult) <= 0) {echo"

No record "; exit ;}; // obtain the maximum number of pages MaxPage $ MaxPage = (int) ceil ($ nNumRows/$ gPageSize); if (int) $ page> $ MaxPage) $ page = $ maxPage;?>

<? Echo "page $ page, total $ MaxPage page";?>
<? // Display the table header for ($ iCnt = 0; $ iCnt <mssql_num_fields ($ rresult); $ iCnt ++) {echo" ";}?> <? // According to the offset ($ page-1) * $ gPageSize, use the mssql_data_seek function to obtain the page to be displayed if (mssql_data_seek ($ rresult, ($ page-1) * $ gPageSize )) {$ I = 0; // The current record set is displayed cyclically for ($ I; $ I <$ gPageSize; $ I ++) {echo" "; // Get the current record and fill it in the array $ arr; $ arr = mssql_fetch_row ($ rresult); if ($ arr) {// all field values of the current record are displayed cyclically for ($ nOffSet = 0; $ nOffSet <count ($ arr); $ nOffSet ++) {echo" ";}} Echo" ";}}?>
". Mssql_field_name ($ rresult, $ iCnt )."
". $ Arr [$ nOffSet]."

<? // If ($ nNumRows> 1 & $ page> 1) {$ prevPage = $ page-1; echo "homepage"; echo "previous page ";} // next page and last page link if ($ page >=1 & $ page <$ MaxPage) {$ nextPage = $ page + 1; echo "next page "; echo "last page" ;}?>

The above is all the content of this article. I hope it will help you learn php programming.

Articles you may be interested in:
  • An example of PHP + MSSQL paging
  • Php mssql database paging SQL statement
  • Continuous impact of php mssql paging SQL statement optimization
  • Exquisite and beautiful php paging code
  • ThinkPHP paging usage
  • Beautiful paging method implemented by php
  • ThinkPHP usage tips-usage of pagination pages
  • ThinkPHP method for retaining the search status by page
  • Php + ajax implementation of refreshing pagination
  • How to maintain conditional paging on the home page and search page during Thinkphp search

Http://www.bkjia.com/PHPjc/1119961.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/1119961.htmlTechArticlePHP MSSQL paging instance, phpmssql paging instance this article examples for you to share the php mssql can refresh paging instance, the specific content of the following php/* 'page description: */$ link = mssql_connect ("mysql20...

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.