Evaluate the page turning effect of PHP + SQLServer & lt ;! DOCTYPE & nbsp; html & nbsp; PUBLIC & nbsp; "-// W3C // DTD & nbsp; XHTML & nbsp; 1.0 & nbsp; Transitional // EN" & nbsp; "http://www.w3.org for PHP + SQLServer flip effect
Paging instance
Error_reporting (7 );
// Initialize paging link parameters
$ Page = $ _ GET ["page"] + 0; // do you want to forcibly convert an integer to an integer?
$ Page = $ page <= 0? 1: $ page; // avoid the negative and 0 values of $ _ GET ["page "].
// Page size
$ Page_size = 10;
$ ServerName = "(local)"; // address of the database server
$ Uid = "sa"; // database username
$ Pwd = "ulptfstx"; // database password
$ ConnectionInfo = array ("UID" => $ uid, "PWD" => $ pwd, "Database" => "MSD ");
$ Conn = sqlsrv_connect ($ serverName, $ connectionInfo );
If ($ conn = false ){
Echo "connection failed! ";
Die (print_r (sqlsrv_errors (), true ));
}
// Calculate the total number of rows
$ Total_records = sqlsrv_num_rows (sqlsrv_query ("SELECT MB001 from INVMB "));
// Total number of pages
$ Total_page = ceil ($ total_records/$ page_size); // perform an integer operation in one step to avoid the last page being less than $ page_size,
$ Page = $ page> $ total_page? $ Total_page: $ page; // avoid the value of $ _ GET ["page"] greater than the total number of pages
// Page turning link starts
$ Page_link = "";
If ($ total_page> 1)
{
$ Page_link = "total {$ total_page} pages ";
$ Page_link. = "current page {$ page ";
$ Page_link. = "homepage ";
If ($ page> 1 ){
// When the page number is greater than 1, the previous page flip link is displayed.
$ Pre_page = $ page-1;
$ Page_link. = "<";
}
// Flip list
For ($ I = 1; $ I <= $ total_page; $ I ++)
{
If ($ I = $ page)
{
// Highlight the current page number
$ Page_link. = "$ I ";
}
Else
{
$ Page_link. = "$ I ";
}
}
// When the page number is smaller than the total page number, the next page flip link is displayed.
$ Next_page = $ page + 1;
If ($ next_page <$ total_page)
{
$ Page_link. = "> ";
}
$ Page_link. = "Last page ";
}
// Output record
$ Offset = ($ page-1) * $ page_size;
$ Query = sqlsrv_query ("select * from INVMB limit $ offset, $ page_size") or die (sqlsrv_error ());
Echo"
";
While ($ rs = sqlsrv_fetch_array ($ query ))
{
Echo"
- {$ Rs ["0"]}-{$ rs ["1"]}
";
}
Echo"
";
Echo "$ page_link ";
?>
This code is from http://topic.csdn.net/u/20120117/11/c2618d08-b88c-4586-8b00-f1938f5c7792.html
How can I change it to connect to SQLServer? the following error is prompted during running:
Warning: sqlsrv_query() expects at least 2 parameters, 1 given in D:\Apache server\Apache\htdocs\bbs\demo.php on line 33