Welcome Guest, Not a member yet? Register   Sign In
pagination for search result
#1

[eluser]harshitha[/eluser]
public function search() {

$q=$_POST['q'];
$config = array();
$config["base_url"] = base_url()."welcome/example1/";
$config["total_rows"] = $this->Countries->record_count($q);
$config["per_page"] = 1;
$config["uri_segment"] = 3;

$this->pagination->initialize($config);

$page = ($this->uri->segment(3)) ? $this->uri->segment(3) : 0;
$data["results"] = $this->Countries->fetch_countries($config["per_page"], $page,$q);
$data["links"] = $this->pagination->create_links();

$this->load->view("search", $data);
}




I use that code to show my search result, But when I clicked "2"or "3" linked in pager

it give following error, I am new to codeiganter,

A PHP Error was encountered

Severity: Notice

Message: Undefined index: q

Filename: controllers/welcome.php

Line Number: 23




#2

[eluser]Pedroshow[/eluser]
Code:
public function search() {      
$q = $this->input->post();

$config = array(
  “base_url”  => base_url().“welcome/example1/”
  “total_rows”  => $this->Countries->record_count($q),
  “per_page”  => 1,
  “uri_segment”  => 3
);

$this->pagination->initialize($config);

$page = ($this->uri->segment(3)) ? $this->uri->segment(3) : 0;
$data[“results”]  = $this->Countries->fetch_countries($config[“per_page”], $page,$q);
$data[“links”]  = $this->pagination->create_links();

$this->load->view(“search”, $data);
}




Theme © iAndrew 2016 - Forum software by © MyBB