php分页出错,php中的分页错误

我已经实现了

this pagination class

在一个名为

class.pagination.php类

,但是当我执行搜索页面时,什么也没有发生。它只是显示一个空白页。

这是我的search.php文件,我在其中调用这个类:

include 'config.php';

require ('class.pagination.php');

$search_result = "";

$search_result = $_GET["q"];

$search_result = trim($search_result);

//Check if the string is empty

if ($search_result == "") {

echo "

Search Error. Please Enter Your Search Query.

" ;

exit();

}

//search query for multiple keywords

if(!empty($search_result))

{

// the table to search

$table = "thquotes";

// explode search words into an array

$arraySearch = explode(" ", $search_result);

// table fields to search

$arrayFields = array(0 => "cQuotes");

$countSearch = count($arraySearch);

$a = 0;

$b = 0;

$query = "SELECT cQuotes, vAuthor, cArabic, vReference FROM ".$table." WHERE (";

$countFields = count($arrayFields);

while ($a < $countFields)

{

while ($b < $countSearch)

{

$query = $query."$arrayFields[$a] LIKE '%$arraySearch[$b]%'";

$b++;

if ($b < $countSearch)

{

$query = $query." AND ";

}

}

$b = 0;

$a++;

if ($a < $countFields)

{

$query = $query.") OR (";

}

}

$query = $query.")";

$result = mysql_query($query, $conn)

or die ('Error: '.mysql_error());

$totalrows = mysql_num_rows($result);

if($totalrows < 1)

{

echo 'No matches found for "'.$search_result.'"';

}

else

{

?>

Search Results

$cQuote = highlightWords(htmlspecialchars($row['cQuotes']), $search_result);

?>

<?php h($row['cArabic']); ?><?php echo $cQuote; ?><?php h($row['vAuthor']); ?><?php h($row['vReference']); ?>

}

}

else {

exit();

}

//Setting Pagination

$pagination = new pagination();

$pagination->byPage = 5;

$pagination->rows = $totalrows; // number of records in a table-back mysql_num_rows () instance or another, you have to play

$from = $pagination->fromPagination(); // sql used for applications such LIMIT $ from, $ pagination-> byPage

$pages = $pagination->pages();

if(isset($pages)) {?>

}

//End Pagination

?>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值