[eluser]Devon Lambert[/eluser]
Ok,
I have no idea how I did it, but I've managed to break the pagination class, yet again.
I've been at this for about 1.5 hours now and I think it's time for bed. Before I retire, I wanted to submit this to the community and see if anyone may be able to assist?
I am able to get the first search page to show in the pagination but after that, my keyword/post data is lost, even though it should be getting pulled from the uri.
Here is the Search Controller:
Code:
<?php
class search extends Controller {
function search()
{
parent::Controller();
$this->load->model('mdl_search');
}
function index()
{
$data['title'] = "MY SEARCH FUNCTION";
if ($this->input->post('keyword') != '') {
$keyword = $this->input->xss_clean($this->input->post('keyword'));
}
else {$keyword = $this->uri->segment(2);}
$data['count_results'] = $this->mdl_search->countResults($keyword);
$this->load->library('pagination');
$config['base_url'] = site_url('search/' . url_title($keyword));
$config['total_rows'] = $data['count_results'];
$config['uri_segment'] = '3';
$config['per_page'] = '10';
$this->pagination->initialize($config);
$offset = $this->uri->segment(3);
$data['search_results'] = $this->mdl_search->getSearchResults($keyword, $config['per_page'], $offset);
$this->load->view('arcade/header');
$this->load->view('arcade/search', $data);
$this->load->view('arcade/footer');
}
}
?>
Here is the view:
Code:
<div class="search">
<?php if(isset($search_results) && !empty($search_results)) { ?>
<h2><?= $title;?></h2>
<div class="pagination"><?php echo $this->pagination->create_links(); ?></div>
<table class="search-results">
<tr class="headerRow">
<th class="gameTitle"><a href="#"><span>Game Title</span></a></th>
<th class="active"><a href="#"><span>Players</span></a></th>
<th><a href="#"><span>Rating</span></a></th>
<th><a href="#"><span>Reviews</span></a></th>
<th><a href="#"><span>Play Type</span></a></th>
</tr>
<? foreach ($search_results as $search_result): ?>
<tr class="alt">
<td class="title"><a href="#"><img src="<?php echo base_url() ?>images/img/<?php echo $search_result['nameid'];?>.png" alt="<?php echo $search_result['name'];?>" width="60" height="50"></a><div class="fltLft"><a href="#"><?php echo $search_result['name'];?></a><br /><?php echo $search_result['desc'];?></div></td>
<td class="players">1,262</td>
<td class="ratings"><b>5.00</b><br />out of 5.0</td>
<td class="reviews"><span class="up">72%</span><br />491 reviews</td>
<td><a href="#" class="btnSearchPlayNow clearLink">play now</a><a href="/servlet/DownloadEcommTracker?sku=texttwist&promoCode=SearchList" class="#">download</a></td>
</tr>
<? endforeach; ?>
</table>
<?php } else { ?>
<h3>You didn't enter a search result, please re-renter.</h3>
<?php } ?>
</div>
Thanks to any who may help. :-)