搜索分页不起作用

时间:2013-12-13 09:13:19

标签: php mysql search pagination

我正面临着搜索不工作的问题。我正在尝试使用搜索对数据进行分页,但第二页和第三页上没有数据分页。请帮助我。我的代码在哪里。

function paginationData($str,$num,$start,$sql,$perpage){
  $pagination = new Pagination; 
  $config['base_url'] = $str;
  $config['total_rows'] = $num;
  $config['per_page'] = $perpage;
  $config['cur_page'] = $start;
  $config['prefix'] = '&p=';
  $config['next_link'] = 'Next';
  $config['prev_link'] = 'Previous';
  $pagination->initialize($config); 
  $sql .= " LIMIT ".$start." , ".$config['per_page'];
  $res = qry($sql,2);   
  $data['listArr'] = $res;  
  $data['Total'] = $num;    
  $data['links'] =  $pagination->create_links();
  $data['per_page'] = $config['per_page']; 
  return $data;
}

$where = '';
$order_by = " ORDER BY parent_id,id_category ASC";  
$search = '';
$search = $_REQUEST['search'];
$search_term = $_REQUEST['word_search'];
if(@$search_term)
    $where = " where name like '%".$search_term."%'";
$sql = "select id_category,name,parent_id from category".$where.$order_by;      
$total_rec = qry($sql,3);
$page = $base_url.'categories.php?word_search='.$search_term;
$start = $_GET['p']?$_GET['p']:0;
//echo "<pre>";
//print_r ($total_rec);
//die();
$perpage=10;
$data = paginationData($page,$total_rec,$start,$sql,$perpage);

0 个答案:

没有答案