Php + mysql intra-site search + paging. below is the intra-site search section (displayed), which cannot be divided by page, as my life forced me to complete this project to others while learning, and all the templates were not used, the following code could not be submitted by Baidu, so I 'd like to ask for help.
If (isset ($ _ POST ['search']) and $ _ POST ['search']! = Null ){
$ Result = mysql_query ("select * from tb_members where shopname like '%". $ _ POST ['search']. "% '");
$ Info = mysql_fetch_array ($ result); if ($ info> = 1 ){
While ($ info = mysql_fetch_array ($ result) {?>
">
}
} Else {
Echo "no content you want to find! ";
}
}
?>
Reply to discussion (solution)
Paging is a very basic part. I don't provide the solution code. I just found the php + mysql paging instance code on the disc on the book I bought a few years ago, I hope you can understand the usage of pagination.
$ TotalPages) $ pageNum = $ totalPages; // set the starting line number $ startRow = ($ pageNum-1) * $ maxRows; // add the LIMIT clause $ SQL _limit = sprintf ("% s LIMIT % d, % d", $ SQL, $ startRow, $ maxRows) for the query statement ); // send the query statement $ rs = mysql_query ($ SQL _limit) or die (mysql_error (); // Obtain a row of records from the record set $ row = mysql_fetch_row ($ rs);?>
Display records by page
Display records by page
\ N "); $ colNum = mysql_num_fields ($ rsAll); for ($ I = 0; $ I <$ colNum; $ I ++) {$ meta = mysql_fetch_field ($ rsAll); printf ("
| % S | \ N ", $ meta-> name);} print ("
\ N "); do {print ("
\ N "); for ($ I = 0; $ I <$ maxRows; $ I ++) printf ("
| % S | \ N ", $ row [$ I]); print ("
\ N ") ;}while ($ row = mysql_fetch_row ($ rs);?>
I have a lot of pages. I can't use the search code above (the search code can be used), and my pages are available elsewhere.