PHP MSSQL Page instance, phpmssql page Instance _php tutorial

Source: Internet
Author: User
Tags learn php learn php programming mssql server

PHP MSSQL Paging instance, Phpmssql pagination instance


Examples of this article for everyone to share the PHP MSSQL can refresh page instances, the specific content is as follows

<?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 = "";//$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 isn't in (select top.) ($page-1) * $pagesize). "ID from Reguser ORDER BY id DESC", ORDER BY id Desc ", $sql =mssql_query ($sqlstr); $result =" "; while ($re Sult=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 first $page page"; if ($page!=1) {echo "Home"; echo "Prev";} if ($page < $pagecount) {echo "next page"; echo "Last";}}? >

Below for everyone to share the Php+mssql General page formula, for your reference, the specific content as follows

<?php//phpinfo ();//$conn =mssql_connect (' 192.168.0.3 ', ' app ', ' web ') or Die (Mssql_get_last_message ());//if ($conn )//{//?echo "Success";//}else{//?echo "fail";//}?><title>PHP Paging</title>< $gPageSize = 10; The number of records displayed per page $hostname = "."; MsSQL server$dbuser = "sa"; User name $dbpasswd = ""; Password//connection Database $id = Mssql_connect ($hostname, $dbuser, $dbpasswd) or die ("Unable to connect to database server! $db = mssql_select_db ("Phmis04", $id) or die ("Unable to connect to the database! ");//take the XXX table for example, build the query string $query =" SELECT Top 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 joins Mate_info on ag_mate=mi_id joins Appl_unit on Au_id=ag_unit; "; /Execute Query Statement $rresult = Mssql_query ($query) or Die ("Unable to execute SQL: $query"),//$page variable to indicate the currently displayed page if (!isset ($page)) $page =1;if ($page = =0) $page =1;//Gets the number of records currently queried $nNumRowsif (($nNumRows = Mssql_num_rows ($rresult)) <=0) {echo]

No record "; exit;};/ /Get maximum page number maxpage$maxpage = (int) ceil ($nNumRows/$gPageSize), if (int) $page > $MaxPage) $page = $maxPage;? >

<? echo "Page $page, total $MaxPage pages";? >
<?//Display the table header for ($iCnt = 0; $iCnt < Mssql_num_fields ($rresult); $iCnt + +) {Echo " ;}? > <?//based on the offset ($page-1) * $gPageSize, use the Mssql_data_seek function to get the page if (Mssql_data_seek ($rresult, ($page-1) * $gPageSize) to be displayed {$i =0;//loop displays the current recordset for ($i; $i < $gPageSize; $i + +) {echo " ";//Get the current record, populate the array with $arr; $arr = Mssql_fetch_row ($rresult), if ($arr) {//cycle displays all field values for the current record for ($nOffSet = 0; $nOffSet < count ( $arr), $nOffSet + +) {echo " ";}} echo " ";}}? >
". Mssql_field_name ($rresult, $iCnt)."
". $arr [$nOffSet]."

<?//Home and Previous page links if ($nNumRows >1 && $page >1) {$prevPage = $page-1; echo "Home"; echo "Prev";} Next and last links if ($page >=1 && $page < $MaxPage) {$nextPage = $page +1;echo "Next page"; Echo "last";}? >

The above is the whole content of this article, I hope that you learn PHP programming help.

Articles you may be interested in:

    • An example of a Php+mssql page
    • PHP MSSQL Database Paging SQL statement
    • PHP MSSQL Paging SQL statement optimizes continuous impact
    • Beautiful PHP Pagination Class code
    • Thinkphp the use of pagination class
    • A nice paging method implemented by PHP
    • thinkphp use of experience sharing-page class page usage
    • thinkphp How to keep pagination in search state
    • Php+ajax implementation of no-refresh paging method
    • Thinkphp method of maintaining conditional paging for home page and search page when searching

http://www.bkjia.com/PHPjc/1119961.html www.bkjia.com true http://www.bkjia.com/PHPjc/1119961.html techarticle PHP MSSQL Page instance, Phpmssql page instance for everyone to share the PHP MSSQL can refresh page instances, the specific content as follows 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.