Novice paging problem, PHP paging generation query function, no query results on the error?
PHP Code
Include ("conn.php"), function pager ($rows, $page _size) {global $page, $select _from, $select _limit, $pagenav; $page _ Count = Ceil ($rows/$page _size); if ($page <= 1 | | $page = = ") $page = 1; if ($page >= $page _count) $page = $page _count; $select _limit = $page _size; $select _from = ($page-1) * $page _size. ', '; $pre _page = ($page = = 1)? 1: $page-1; $next _page= ($page = = $page _count)? $page _count: $page + 1; $pagenav. = "$page/$page _count page Total $rows records"; $pagenav. = "Home"; $pagenav. = "Previous page"; $pagenav. = "Next page"; $pagenav. = "Last"; $pagenav. = "Jump to\ n "; for ($i =1; $i <= $page _count; $i + +) {if ($i = = $page) $pagenav. = "$i\ n "; else $pagenav. = "$i\ n "; }}/////////////////////////////uses the pager function to calculate the $select _from from which record to start the retrieval, $pagenav output paging navigation $countsql = "SELECT * from manager WH Ere 0=0 "; if ($_post[chinaname]!= "") {$countsql = $countsql. "And chinaname like '%$_post[chinaname]% '"; } if ($_post[tel]!= "") {$countsql = $countsql. "And Tel like '%$_post[tel]% '"; } $rows = Mysql_num_rows (mysql_query ($countsql)); $page = $_get[' page '];p ager ($rows, 2); $sql = "SELECT * from manager where 0=0"; if ($_post[chinaname]!= "") {$sql = $sql. "And chinaname like '%$_post[chinaname]% '"; } if ($_post[tel]!= "") {$sql = $sql. "And Tel like '%$_post[tel]% '"; } $sql = $sql. "Limit $select _from $select _limit"; echo $sql; $rst = mysql_query ($sql); while ($row =mysql_fetch_array ($rst)) {Now the problem is that when I blur the query with no results, the statement shown here is limit-2,2Do you think this question should be solved at the moment?------Solution--------------------$page _count = ceil ($rows/$page _size);No results when the $rows is 0, the resulting $page_count is equal to 0, so the following$select _from = (0-1) * 2 $select _from got--2.You can add a judgment $page _count to 0 without the limit clause