[eluser]Bramme[/eluser]
Dunno if this is the solution, but I would restructure the way you're approaching your $keyword handling. I would go about it this way:
controller:
Code:
<?php
class search extends Controller {
function search()
{
parent::Controller();
$this->load->model('mdl_search');
$this->load->helper('url');
$data['title'] = "MY SEARCH FUNCTION";
$this->load->vars($data);
}
function index()
{
if($this->input->post('submit') != false)
{
$keyword = $this->input->post('keyword', true); //parses it through the XSS filter
redirect("/search/keyword/$keyword");
}
$this->load->view('searchform');
}
function keyword()
{
$keyword = $this->uri->segment(3, null);
if(!isset($keyword))
{
redirect('/search'); // extra precaution
}
$data['count_results'] = $this->mdl_search->countResults($keyword);
$this->load->library('pagination');
$config['base_url'] = site_url('search/keyword/' . url_title($keyword));
$config['total_rows'] = $data['count_results'];
$config['uri_segment'] = '4';
$config['per_page'] = '10';
$this->pagination->initialize($config);
$offset = $this->uri->segment(4, 0);
$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');
}
}
?>
searchform view:
Code:
<form action="/search/" method="post">
<input type="text" name="keyword" />
<input type="submit" name="submit" value="Submit search" />
</form>
and your final view
Code:
<div class="search">
<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>
</div>
(now there's no if)
Try this. I hope it works, didn't test it.
note: you should also handle "no search results"