[eluser]Jamongkad[/eluser]
Hi guys I'm thinking this is a simple problem that could be linked but right now I'm pretty stumped. Anyways I have this search function...I use pagination to display the results. Thankfully I can control the amount of information displayed. The problem is the over run cannot be view after you click on the links to see more. Lets say for example there are 10 items found. I had the pagination lib limit it to 4, so there are links for extra information right? when I click on them the DB returns no results. When I go back to the first link no information too. It's like there was no information in the first place. Anyways here's the code hope we could solve this one...
Controller
Code:
function search()
{
$this->load->library('pagination');
$config['base_url'] = base_url().'sprocket/search';
$config['total_rows'] = $this->db->count_all('sprocket_upload');
$config['per_page'] = '4';
$config['full_tag_open'] = '<p>';
$config['full_tag_close'] = '</p>';
$config['cur_tag_open'] = '<em>';
$config['cur_tag_close'] = '</em>';
$num = $config['per_page'];
$offset = $this->uri->segment(3);
$this->pagination->initialize($config);
$datas['page_links'] = $this->pagination->create_links();
$search_query = $this->input->post('search_box');
$datas['result'] = $this->sprocketeer->fetchSearchResults($search_query,$num,$offset);
$data['title'] = "Sprocket Fish: Search Results";
$data['header'] = $this->load->view('snippets/header.php','',TRUE);
$data['content'] = $this->load->view('app/sprocket/search_results.php',$datas,TRUE);
$data['footer'] = $this->load->view('snippets/footer.php','',TRUE);
$this->load->view('layout.php',$data);
}
Model
Code:
function fetchSearchResults($search_query, $num, $offset)
{
$results = $this->db->query($sql);*/
if($search_query != FALSE)
{
$this->db->like('tags',$search_query);
$this->db->orderby('tags');
$results = $this->db->get('sprocket_upload', $num, $offset);
return $results->result_array();
}
}
view
Code:
<!--Search Results-->
<?php if(!empty($result)){ ?>
<table>
<tr>
<?php foreach($result as $rows): ?>
<td class="displayResults"><p>
Tags: <?php
$pack = unserialize($rows['tags']);
foreach($pack as $key=>$value){
echo $value.", ";
}
?><br/>
Sprocket Name:<?php echo $rows['sprocket_name']; ?>
</p>
<p><span class="imgDetails"><?php echo anchor('sprocket/viewSprocket/'.$rows['id'],'Image Details '); ?></span><span class="pricingInfo"><?php echo anchor('sprocket/viewSprocket/'.$rows['id'],'Pricing Info'); ?></span></p>
<img src="<?php echo base_url(); ?>sprocket_files/<?php echo $rows['file_name']; ?>" />
</td>
<?php endforeach; ?>
</tr>
</table>
<?php } else { ?>
<div class="searchBox"><p>No results returned.</p></div>
<?php } ?>
<!--EOF Search Results-->
<?php echo $page_links; ?>