[英]Search Limit Query and paging php mysqli wgen search anything
When I search then All rows/querys display.当我搜索时,所有行/查询都会显示。 That's why page loading is too slow.
这就是页面加载太慢的原因。
I want to show only 100 rows/querys with paging when I will search something.当我搜索某些内容时,我只想通过分页显示 100 行/查询。
or make it faster if any modification need.如果需要任何修改,或使其更快。
Please请
$sql = "SELECT * FROM crawl WHERE title LIKE '%".$strKeyword."%' "; $query = mysqli_query($conn,$sql);
$num_rows = mysqli_num_rows($query);
$per_page = 2; // Per Page $page = 1;
if(isset($_GET["Page"])) { $page = $_GET["Page"]; }
$prev_page = $page-1; $next_page = $page+1;
$row_start = (($per_page*$page)-$per_page); if($num_rows<=$per_page) { $num_pages =1; } else if(($num_rows % $per_page)==0) { $num_pages
=($num_rows/$per_page) ; } else { $num_pages =($num_rows/$per_page); $num_pages = (int)$num_pages; } $row_end = $per_page * $page; if($row_end > $num_rows) { $row_end = $num_rows; }
$sql .= "ORDER BY id, title, ogimage DESC LIMIT $row_start ,28 "; $query = mysqli_query($conn,$sql);
LIKE
starting with a wild card is slow because it cannot use an index LIKE
以通配符开头很慢,因为它不能使用索引FULLTEXT
, together with MATCH
is much faster, but has limitations. FULLTEXT
与MATCH
一起更快,但有局限性。OFFSET
has several problems, including performance. OFFSET
的行有几个问题,包括性能。 See Pagination见分页
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.