Welcome Guest, Not a member yet? Register   Sign In
problem with url
#11

[eluser]kv[/eluser]
ok let me explain .
Here is my controller code plz see the below.

file one controller:

class Contact_list extends Controller
{
function Contact_list() {
parent::Controller();
$this->load->helper(’url’);
$this->load->library(’session’);
$this->load->database();
$this->admin_url =$this->config->item(’admin_url’);
}

function index()
{

//load pagination class
$this->load->library(’pagination’);
$config[’base_url’] = $this->admin_url.’/contact_list/index/’;
$config[’total_rows’] = $this->db->count_all(’tbl_contact’);
$config[’per_page’] = ‘1’;
$config[’full_tag_open’] = ‘<p>’;
$config[’full_tag_close’] = ‘</p>’;

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

//load the model and get results
$this->load->model(’contact_model’);
echo $this->uri->segment(4);

$data[’results’] = $this->contact_model->get_books($config[’per_page’],$this->uri->segment(4));

// load the HTML Table Class
$this->load->library(’table’);
$this->table->set_heading(’First Name’, ‘Last Name’, ‘Email’, ‘Contact Date’,’Action’);

// load the view
$this->load->view(’admin/contactlist_form’, $data);
}
}

///model////
class contact_model extends Model {

function __construct(){
parent::Model();
}

function get_books($num, $offset) {
$query = $this->db->get(’tbl_contact’, $num, $offset);

return $query;
}
}

view page:

$this->load->view($this->config->item(’ADMIN_dir’).’header’);
$admin_url =$this->config->item(’admin_url’);

echo $this->table->generate($results);
echo $this->pagination->create_links();
$this->load->view($this->config->item(’ADMIN_dir’).’footer’);
#12

[eluser]pr0digy[/eluser]
I think you're missing this bit of code:

Code:
$config['uri_segment'] = 4;

Without it, the pagination class may not determine correct offset.
#13

[eluser]kv[/eluser]
Thanks its working now.
but i have facing a another problem when i have to click on the link(1,2,3).in the url its display this
address(http://fedoraserver/therapist/production...st/index/1).
now i have to click on the another menu but its display this url (http://fedoraserver/therapist/production...ews_letter)
or this url can't be worked.
#14

[eluser]Michael Wales[/eluser]
Are you using the 4th segment for some sort of work in your controller as well? For instance, does news_letter mean something to you in the 2nd URL you posted?

If so, change the uri segment pagination uses to 5 so it doesn't overwrite the segment you are using.
#15

[eluser]kv[/eluser]
thanks a lot .
every thing working as fine.




Theme © iAndrew 2016 - Forum software by © MyBB