Today in the spare time to write a section of PHP paging processing script, Welcome to shoot Bricks!!! Show Page index.php
Paging processing function showbbsprocess.php
Author: '. $arr [$i] [' poster ']. ' '.' Release time: '. $arr [$i] [' posted ']. '
';//If the elements in the $arr array, that is, $i ($i starting from 0) are equal to the number of elements in the array minus one, then jump out of the 2-layer loop (for loop and foreach Loop) if ($i = = (count ($arr)-1) Break 2;}} $RowCount =getrowcount ($connectmysql);//Total number of records $pagecount=ceil ($RowCount/$PageSize);//A few pages, ceil () function in a full echo ' Post stats: '. $RowCount. '. ' '.' Total '. $PageCount. ' page ';//when the first page does not output "previous" if ($CurrentPageID! = 1) {echo "previous";} Forward page if ($CurrentPageID > 2) {echo "<<<";} Output a detailed number of pages, such as: "1" for ($j =1; $j <= $PageCount; $j + +) {echo "[$j]";} Skip Backward if ($CurrentPageID <= ($PageCount-2)) {echo ">>>"} When the last page is not output "next" if ($CurrentPageID! = $PageCount) {echo "next page";} $connectmysql->closeconn ();}
The function of communicating with the database showbbs_fun.php
Getrowsarray ($sql); return $arr 1;} The number of rows in the table that the function uses to query the database function GetRowCount ($connectmysql) {$sql = "select * from Db_content"; $num = $connectmysql Getrowsnum ($sql); return $num;}
Database Class connectmysql.php
Conn=mysql_connect ($this->host, $this->username, $this->password); @mysql_select_db ($this->dbname,$ This->conn); mysql_query (' Set names Utf-8 ');} Query result function GetResult ($sql) {if ($this->conn== ") {$this->conndb ();} $this->result=mysql_query ($sql, $this->conn);} Returns the number of records in the query function Getrowsnum ($sql) {$this->getresult ($sql), $num _rows=mysql_num_rows ($this->result); Mysql_errno () ==0) {return $num _rows;} else {return ';}} Outputs the result as an array of single records and returns the function GetArray ($sql) {$this->getresult ($sql); if (Mysql_errno () ==0) {$this->resultarray =mysql_fetch_array ($this->RESULT,MYSQL_ASSOC);//Get associative array return $this->resultarray;} else {return ';}} Returns a two-dimensional array that contains multiple records function Getrowsarray ($sql) {$this->getresult ($sql), if (Mysql_errno () ==0) {while ($row =mysql_ Fetch_array ($this->result,mysql_assoc)) {$this->rowsarray[]= $row;} return $this->rowsarray;//print_r ($this->rowsarray); exit;} else {return ';}} Update, add, delete function Uidresult ($sql) {if ($this->conn== ') {$this->conndb();} echo $sql;//exit; @mysql_query ($sql); $this->rowsnum= @mysql_affected_rows (); if (Mysql_errno () ==0) {return $ This->rowsnum;} else {return ';}} Release result set function Freeresult () {mysql_free_result ($this->result), $this->rowsnum=0; $this->rowsarray= "; This->resultarray= ';} Close Database function Closeconn () {$this->freeresult (); Mysql_close ($this->conn); $this->conn= ";}}
http://www.bkjia.com/PHPjc/755766.html www.bkjia.com true http://www.bkjia.com/PHPjc/755766.html techarticle today in the spare time to write a section of PHP paging processing script, Welcome to shoot Bricks!!! Show page index.php paging processing function showbbsprocess.php Author: '. $arr [$i] [' poster ']. ' '.' When publishing ...