我在页面中有一个搜索字段。但如果没有匹配的结果,则会抛出错误“致命错误:调用非对象上的成员函数 show()”。我附上了截图。
<?php
if ( isset($_REQUEST['usersearch']) && $_REQUEST['usersearch'] )
printf( '<span class="subtitle">' . __('Search results for “%s”') .
'</span>', esc_html( $_REQUEST['usersearch'] ) );
?>
但错误行是(第 228 行):-
<div class='tablenav-pages'>
<?php echo $p->show(); // Echo out the list of paging. ?>
</div>
我需要删除搜索结果上的错误。它应该只显示“未找到任何项目”。
function pager($items)
{
global $limit;
global $p;
global $searchTerm;
global $pageLimit;
if($items > 0) {
$p = new pagination;
$p->items($items);
$p->limit($pageLimit); // Limit entries per page
$p->target("admin.php?page=User Control&usersearch=".$_REQUEST['usersearch']."&page-limit=".$_REQUEST['page-limit']);
$p->currentPage($_GET[$p->paging]); // Gets and validates the current page
$p->calculate(); // Calculates what to show
$p->parameterName('paging');
$p->adjacents(1); //No. of page away from the current page
if(!isset($_GET['paging'])) {
$p->page = 1;
} else {
$p->page = $_GET['paging'];
}
//Query for limit paging
$limit = "LIMIT " . ($p->page - 1) * $p->limit . ", " . $p->limit;
} else {
echo "No Record Found";
}
}