Php, hybrid editing, and data paging to connect to the database
$ Conn = mysql_connect ('localhost', 'root', 'root') or die ('errorcode: '. mysql_errno ().', Error: '. mysql_error ());
Mysql_select_db ('Company') or die ('errorcode: '. mysql_errno ().', Error: '. mysql_error ());
?>
Paging of mixed data
Test page
Include 'Conn. php ';
$ Pagesize = 10;
Mysql_query ("set names utf8 ");
$ SQL = "SELECT count (*) cnt FROM com_info"; // Retrieve the total number of records
$ R = mysql_query ($ SQL) or die ('error code: '. mysql_errno ().', error: '. mysql_error ());
$ Row = mysql_fetch_assoc ($ r );
$ Total = $ row ['cnt ']; // The total number of records.
$ Total_pages = ceil (intval ($ total)/$ pagesize); // total number of pages
$ Pn = isset ($ _ GET ['Page'])? Intval ($ _ GET ['Page']): 1;
$ Pn <1 & $ pn = 1;
$ Pn >=$ total_pages & $ pn = $ total_pages;
$ Offset = ($ pn-1) * $ pagesize;
$ SQL = "SELECT com, com_name FROM com_info LIMIT {$ offset}, {$ pagesize }";
$ R = mysql_query ($ SQL) or die ('error code: '. mysql_errno ().', error: '. mysql_error ());
?>
No. |
Company name |
While ($ row = mysql_fetch_assoc ($ r )){?>
|
|
}?>
Homepage
For ($ I = 1; $ I <= $ total_pages; $ I ++ ){
?>
"> Page
}
?>
"> Last Page