I have a problem in pagination with search in codeigniter
URL is not change when select the other page link
the data is not change when select the other link
This my controller
public function search_code(){
$this->load->library('pagination');
$param = new stdClass();
$param->item_code = $this->input->get('by_item_code');
$param->description = $this->input->get('by_description');
if (!isset($page) || $page == '') {
$page = 1;
}
$param->per_page = 50;
$param->limit = ($page - 1) * $param->per_page;
$paginate_url = base_url('warehouse/search_code?item_code='.$param->item_code.'&by_description='.$param->description.'&page='.($page+1));
$data['total_result'] = $this->m_stock->count_stock_search ($param);
$config['uri_segment'] = 3;
$config['num_links'] = 4;
$config['base_url'] = $paginate_url;
$config['total_rows'] = $data['total_result'];
$config['per_page'] = $param->per_page;
$config['use_page_numbers'] = TRUE;
$config['page_query_string'] = TRUE;
$this->pagination->initialize($config);
$data['pagination'] = $this->pagination->create_links();
$data['item'] = $this->m_stock->search_code ($param);
$this->load->view('v_all_stocks', $data);
}
This my model
function search_code($param){
$result = array();
$sql = "select ic.id, ic.item_code, ic.description, maxdt.maxdt, lc.balance,lc.dt,lc.createdate,lc.id_lines_code, io.ONHANDQTY ";
$sql .= "from tbl_item_code ic ";
$sql .= "left join ( tbl_lines_code lc inner join ( select id, max(createdate) maxdt from tbl_lines_code where active = 1 group by id ) maxdt ";
$sql .= "on lc.id = maxdt.id and lc.createdate = maxdt.maxdt ) on ic.id = lc.id ";
$sql .= "left join item_ostendo io on io.ITEMCODE = ic.item_code ";
$sql .= "where ic.active = 1 ";
if ($param->item_code != '') {
$sql .= "AND ic.item_code LIKE '%$param->item_code%' ";
}
if ($param->description != '') {
$sql .= "AND ic.description LIKE '%$param->description%' ";
}
$sql .= "group by ic.id order by ic.item_code ";
if ($param->limit > 0)
$sql .= " LIMIT ".$param->limit.", ".$param->per_page;
else
$sql .= " LIMIT ".$param->per_page;
$query = $this->db->query($sql);
if ($query->num_rows() > 0) {
$result = $query->result();
}
return $result;
}
and about view i checked it's can working
but i don't know why i select the link of number the data is show like the last page but the number of link is working
Show all data not search yet the link show like this
when search show like this
but when select number 2 of link it's show like this and the data is same every page
You need to change your:
$paginate_url = base_url('warehouse/search_code?item_code='.$param->item_code.'&by_description='.$param->description.'&page='.($page+1));
This:
$config['uri_segment'] = 3;
defines that segment for the offset clause.
I would suggest:
$query = "?item_code='.$param->item_code.'&by_description='.$param->description.'&page='.($page+1))";
$paginate_url = base_url('warehouse/search_code/page/').$query;
$config['uri_segment'] = 4;
Take this as offset:
$param->limit = $this->uri->segment(4);
You have to change paging base url as below :
$paginate_url = base_url('warehouse/search_code').'?item_code='.$param->item_code.'&by_description='.$param->description;
Related
please visite my url and seee
https://staging.raptorsupplies.com/catalogsearch/result/?q=baldwin
you click on first product also you can see this product showing
enter image description here
if click on then it will be showing error like
and if click on other product then it open and working, because variation/collection list have less but it is in 1500 variation
i have create pagination for this request but i am still facing error
you can see my code where is error i think error in pagination but i am get it show please any one can help me
[enter image description here][2]
public function getConfigAttribOption($childProductList, $attribbid = NULL, $AllchildProductList = null) {
$resource = Mage::getSingleton('core/resource');
$readConnection = $resource->getConnection('core_read');
$storeId = Mage::app()->getStore()->getStoreId(); //die;
if ($attribbid > 0) {
$SqlAttributeID = "select distinct attribute_id from eav_attribute_option where option_id in($attribbid)";
$RowAttributeID = $this->executeQuery($SqlAttributeID);
foreach ($RowAttributeID as $arrKey => $Arrval) {
$arrAttributeId[] = $Arrval['attribute_id'];
}
$attributeids = implode(',', $arrAttributeId);
$sqlConfigurableAttribute = "select a.attribute_id as id,a.frontend_label as label,a.attribute_code as attribute_code,group_concat(distinct i.value) as option_id,GROUP_CONCAT(DISTINCT o.value SEPARATOR '&|&') as option_value from catalog_product_entity_int as i join eav_attribute as a on i.attribute_id=a.attribute_id JOIN eav_attribute_option_value AS o ON i.value=o.option_id where o.store_id=".$storeId." and (a.attribute_id in(81,92) OR a.attribute_id>20000) and entity_id in($childProductList) AND a.attribute_id NOT IN($attributeids) group by i.attribute_id having count(distinct i.value)>1";
$arrCount = 0;
mysql_query('SET SESSION group_concat_max_len=10000');
foreach ($arrAttributeId as $key => $val) {
if ($arrCount == count($attribbid) - 1) {
$sqlCheckedAttribute.=" union all SELECT a.attribute_id AS id,a.frontend_label AS label,a.attribute_code AS attribute_code,IF(COUNT(DISTINCT i.value)>1,GROUP_CONCAT(DISTINCT i.value),'') AS option_id,GROUP_CONCAT(DISTINCT o.value SEPARATOR '&|&') AS option_value FROM catalog_product_entity_int AS i JOIN eav_attribute AS a ON i.attribute_id=a.attribute_id JOIN eav_attribute_option_value AS o ON i.value=o.option_id WHERE o.store_id=".$storeId." and (a.attribute_id in(81,92) OR a.attribute_id>20000) AND entity_id in(" . $AllchildProductList . ") AND a.attribute_id=" . $val . " GROUP BY i.attribute_id ";
} else {
$sqlCheckedAttribute.=" union all SELECT a.attribute_id AS id,a.frontend_label AS label,a.attribute_code AS attribute_code,IF(COUNT(DISTINCT i.value)>1,GROUP_CONCAT(DISTINCT i.value),'') AS option_id,GROUP_CONCAT(DISTINCT o.value SEPARATOR '&|&') AS option_value FROM catalog_product_entity_int AS i JOIN eav_attribute AS a ON i.attribute_id=a.attribute_id JOIN eav_attribute_option_value AS o ON i.value=o.option_id WHERE o.store_id=".$storeId." and (a.attribute_id in(81,92) OR a.attribute_id>20000) AND entity_id in(" . $AllchildProductList . ") AND a.attribute_id=" . $val . " GROUP BY i.attribute_id ";
}
$arrCount = $arrCount + 1;
}
$sqlConfigurableAttribute = $sqlConfigurableAttribute . $sqlCheckedAttribute;
} else {
$sqlConfigurableAttribute = "select a.attribute_id as id,a.frontend_label as label,a.attribute_code as attribute_code,group_concat(distinct i.value) as option_id,GROUP_CONCAT(DISTINCT o.value SEPARATOR '&|&') as option_value from catalog_product_entity_int as i join eav_attribute as a on i.attribute_id=a.attribute_id JOIN eav_attribute_option_value AS o ON i.value=o.option_id where o.store_id=$storeId and (a.attribute_id in(81,92) OR a.attribute_id>20000) and entity_id in($childProductList) group by i.attribute_id having count(distinct i.value)>1";
}
$sqlConfigurableAttribute = $sqlConfigurableAttribute . " order by id"; //die;
$productAttributeOptions = $readConnection->fetchAll($sqlConfigurableAttribute);
return $productAttributeOptions;
}
public function executeQuery($query) {
$resource = Mage::getSingleton('core/resource');
$readConnection = $resource->getConnection('core_read');
return $readConnection->fetchAll($query);
}
function getRelativeOptionBlock($productId = null, $attribbid = null, $pageno = null) {
$encrypted_string=$this->getRequest()->getParam('active_filters');
$decrypted_string=urldecode(base64_decode($encrypted_string));
if($decrypted_string){
$attribbid=$decrypted_string;
$productId= $this->getProduct()->getId();
}
if ($attribbid && $productId) {
//$childProducts = Mage::getModel('catalog/product_type_configurable')->getChildrenIds($productId);
//$childProductList = implode(',', $childProducts[0]);
$AllchildProducts = Mage::getModel('catalog/product_type_configurable')->getChildrenIds($productId);
$AllchildProductList = implode(',', $AllchildProducts[0]);
$attribb = explode(',', $attribbid);
$query = 'SELECT eav_attribute.attribute_code FROM eav_attribute JOIN eav_attribute_option ON eav_attribute.attribute_id=eav_attribute_option.attribute_id WHERE option_id IN(' . $attribbid . ')';
$results = $this->executeQuery($query);
$attribvalue = $results['0']['attribute_code'];
$product = Mage::getModel('catalog/product')->load($productId);
$childProductsColl = Mage::getModel('catalog/product_type_configurable')
->getUsedProductCollection($product)
->addAttributeToSelect('*');
foreach ($results as $res) {
$childProducts = $childProductsColl->addFieldToFilter($res['attribute_code'], $attribb);
}
$childProductList = array();
foreach ($childProducts as $cp2) {
$childProductList[] = $cp2->getId();
}
$childProductList = implode(',', $childProductList);
} elseif ($productId) {
$childProducts = Mage::getModel('catalog/product_type_configurable')->getChildrenIds($productId);
$childProductList = implode(',', $childProducts[0]);
} else {
$childProducts = Mage::getModel('catalog/product_type_configurable')->getChildrenIds($this->getProduct()->getId());
$childProductList = implode(',', $childProducts[0]);
}
$attributeOptions = array();
$productAttributeTh = array();
$productAttributeId = array();
$resource = Mage::getSingleton('core/resource');
$writeConnection = $resource->getConnection('core_write');
$querytemp="SET group_concat_max_len=100000";
$writeConnection->query($querytemp);
$productAttributeOptions = $this->getConfigAttribOption($childProductList, $attribbid, $AllchildProductList);
Mage::getSingleton('core/session')->setOptionlength(count($productAttributeOptions));
$html = "";
$html .= "<div class='box-container list' style='margin-left: 40px;'>";
foreach ($productAttributeOptions as $productAttribute) {
$productAttributeTh[] = $productAttribute['label'];
$productAttributeThId[] = $productAttribute['id'];
$productAttributeThCode[] = $productAttribute['attribute_code'];
$productAttributeId = array();
$productAttributeVal = array();
$productAttributeId = explode(',', $productAttribute['option_id']);
$productAttributeVal = explode('&|&', $productAttribute['option_value']);
if((int)$productAttribute['id'] == 81)
{
$this->brandcount = count($productAttributeVal);
}
if((int)$productAttribute['id'] == 81 && count($productAttributeVal) ==1)
continue;
$attribute_to= count($productAttributeId);
$attribute_option=array();
for($i=0;$i<$attribute_to;$i++){
$attribute_option[$productAttributeId[$i]]=$productAttributeVal[$i];
}
asort($attribute_option);
$label =$productAttribute['label'];
$html .= "<div class='inner-box-container list-content'>";
$html .= "<p class='new_align' title='".ucwords($productAttribute['label'])."'>" .ucwords($label) . "</p>";
///$productAttributeLbel = $productAttribute['label'];
$productAttributeLbel = preg_replace('/[^A-Za-z0-9\-]/', '', $productAttribute['label']);
$html .= "<script> multiselected('" . str_replace(' ', '', $productAttributeLbel) . "')</script>";
$html .= "<select class='" . str_replace(' ', '', $productAttributeLbel) . "'>";
//echo"<select >";
foreach ($attribute_option as $OptionKey => $OptionVal) {
if((int)$productAttribute['id'] == 81 && count($attribute_option) ==1)
continue;
$attridarray = explode(',', $attribbid);
if (in_array($OptionKey, $attridarray)) {
//echo $attribbid.$OptionVal; die;
$html .= "<option value='" . $OptionKey . "' title='title'>". $OptionVal . "</option>";
} else {
$html .= "<option value='" . $OptionKey ."' >" . $OptionVal . "</option>";
}
}
$html .= "</select>";
$html .= "</div>";
}
Mage::getSingleton('core/session')->setAttributeIds($productAttributeThId);
$html .= "</div><br class='clearBoth' />";
return $html;
}
function getRelativeHeaderBlock($productId = null, $attribbid = null) {
$encrypted_string=$this->getRequest()->getParam('active_filters');
$decrypted_string=urldecode(base64_decode($encrypted_string));
if($decrypted_string){
$attribbid=$decrypted_string;
$productId= $this->getProduct()->getId();
}
if ($productId) {
$childProducts = Mage::getModel('catalog/product_type_configurable')->getChildrenIds($productId);
} else {
$childProducts = Mage::getModel('catalog/product_type_configurable')->getChildrenIds($this->getProduct()->getId());
}
$childProductList = implode(',', $childProducts[0]);
$productAttributeTh = array();
$attribidvalue= array();
if ($attribbid) {
$attribb = explode(',', $attribbid);
$query = 'SELECT * FROM eav_attribute_option where option_id in(' . $attribbid . ')';
$results = $this->executeQuery($query);
foreach($results as $key=>$val){
$attribidvalue[]=$val['attribute_id'];
}
//$attribidvalue = $results['0']['attribute_id'];
}
$productAttributeOptions = $this->getConfigAttribOption($childProductList);
foreach ($productAttributeOptions as $productAttribute) {
$productAttributeTh[$productAttribute['id']] = $productAttribute['label'];
}
$Productdetail = Mage::getModel('catalog/product')->load($productId);
?>
I use pagination for separate data in the view page it's show the links for select page but it's show all data in database (250 data) it's not separate 30 per page. Please Help me
This my model
function get_item_code($param){
$result = array();
$sql = "select ic.id, ic.item_code, ic.description, maxdt.maxdt, lc.balance,lc.dt ";
$sql .= "from tbl_item_code ic ";
$sql .= "left join ( tbl_lines_code lc inner join ( select id, max(dt) maxdt from tbl_lines_code where active = 1 group by id ) maxdt ";
$sql .= "on lc.id = maxdt.id and lc.dt = maxdt.maxdt ) on ic.id = lc.id ";
$sql .= "where ic.active = 1 group by ic.id ";
// echo $sql;
if ($param->limit > 0)
$this->db->limit($param->per_page, $param->limit);
else
$this->db->limit($param->per_page);
$query = $this->db->query($sql);
if ($query->num_rows() > 0) {
$result = $query->result();
}
return $result;
}
This my controller
public function main(){
$this->load->library('pagination');
$page = $this->uri->segment(3);
$param = new stdClass();
if (!isset($page) || $page == '') {
$page = 1;
}
$param->per_page = 30;
$param->limit = ($page - 1) * $param->per_page;
$paginate_url = site_url('warehouse/main');
$data['total_result'] = $this->m_stock->count_stock ();
$config['uri_segment'] = 3;
$config['num_links'] = 4;
$config['base_url'] = $paginate_url;
$config['total_rows'] = $data['total_result'];
$config['per_page'] = $param->per_page;
$config['use_page_numbers'] = TRUE;
$config['page_query_string'] = FALSE;
$this->pagination->initialize($config);
$data['pagination'] = $this->pagination->create_links();
$data['item'] = $this->m_stock->get_item_code($param);
$this->load->view('v_all_stocks', $data);
}
and this my view foe echo $pagination
<?php
if(isset($pagination) && $pagination != ''){
?>
<div class="search_pagination"><?php echo $pagination; ?></div>
<?php } ?>
and use foreach for show data
In controller
function main()
{
$this->load->library('pagination');
$count = $this->m_stock->count_stock();
$config['base_url'] = base_url() . 'warehouse/main/';
$config['total_rows'] = $count;
$config['per_page'] = 30;
$config['uri_segment'] = 3;
$limit = $config['per_page'];
// Bootstrap style
$config['full_tag_open'] = '<ul class="pagination">';
$config['full_tag_close'] = '</ul>';
$config['first_link'] = false;
$config['last_link'] = false;
$config['first_tag_open'] = '<li>';
$config['first_tag_close'] = '</li>';
$config['prev_link'] = '«';
$config['prev_tag_open'] = '<li class="prev">';
$config['prev_tag_close'] = '</li>';
$config['next_link'] = '»';
$config['next_tag_open'] = '<li>';
$config['next_tag_close'] = '</li>';
$config['last_tag_open'] = '<li>';
$config['last_tag_close'] = '</li>';
$config['cur_tag_open'] = '<li class="active"><a href="#">';
$config['cur_tag_close'] = '</a></li>';
$config['num_tag_open'] = '<li>';
$config['num_tag_close'] = '</li>';
$this->pagination->initialize($config);
$page = ($this->uri->segment(3)) ? $this->uri->segment(3) : 0;
$data['links'] = $this->pagination->create_links();
$data['item'] = $this->m_stock->get_item_code($limit,$page);//pass item code here
$this->load->view('v_all_stocks', $data);
}
In model
function get_item_code($limit,$page)
{
$sql = "select ic.id, ic.item_code, ic.description, maxdt.maxdt, lc.balance,lc.dt ";
$sql .= "from tbl_item_code ic ";
$sql .= "left join ( tbl_lines_code lc inner join ( select id, max(dt) maxdt from tbl_lines_code where active = 1 group by id ) maxdt ";
$sql .= "on lc.id = maxdt.id and lc.dt = maxdt.maxdt ) on ic.id = lc.id ";
$sql .= "where ic.active = 1 group by ic.id ";
$sql .= "LIMIT $page, $limit";
$query = $this->db->query($sql);
$result = $query->result_array();
return $result;
}
I have one table korisnik with 3 columns (id, username, password).
I want some like:
$upit = "SELECT * FROM korisnik WHERE username = '" . $_POST['username'] . "'
AND password = SHA1('" . $_POST['password'] . "')";
$temp = $upit->fetch(PDO::FETCH_ASSOC);
$_SESSION['id'] = $temp['id'];
if ($pdo_izraz->num_rows() == 1) {
session_start();
$_SESSION['autorizovan'] = 1;
$temp = $pdo_izraz->fetch(PDO::FETCH_ASSOC);
$_SESSION['id'] = $temp['id'];
$upit = ("Select * from korisnici where id=" . $_SESSION['id']);*
$izraz = $dbh->query($upit);
$obj = $izraz->fetch(PDO::FETCH_ASSOC);
$username = $obj['username'];
echo "<p id='bbb'><b >$username</b>:Welcome</p>";
I want to do something like this in CodeIgniter (to get one row where id=array of one row ($_SESSION['id']
I think you are looking for result_array()
see the manual here
$query = $this->db->query("YOUR QUERY");
foreach ($query->result_array() as $row)
{
echo $row['title'];
echo $row['name'];
echo $row['body'];
}
UPDATE
public function login($user, $pass) // Takeing the username/pass from form
{
$this->db->where('username', $user);
$this->db->where('password', md5($pass));
$query = $this->db->get('korisnici');
if ($query->num_rows() == 1)
{
$_SESSION['id'] = $this->query->row()->id;
return TRUE;
}
else
{
return FALSE;
}
}
public function getData()//Get result of array
{
$this->db->where('id', $_SESSION['id']);
$query = $this->db->get('korisnici');
return $query->result(); // here you can change for result_array() if you want
}
I have 3 tables site_settings,sermons & Preachers. In site_settings table, set the max number of preachers to be displayed. Preacher table contains all the preacher details and sermons table contains sermons of all preachers. Am using pagination for displaying preachers(2/page). if the value of site_settings table is 1 or 2 then no of preachers will display 2, if 3 or 4 then preachers 4... I don't know what is happening. Is it a problem with pagination or limit? I am using the following code for this ( In Model)
Method in Model
function viewAll($offset=0, $limit=null) {
$this->db->select('settings_value');
$this->db->from('site_settings');
$this->db->where('settings_name', 'preachercount');
$count = $this->db->get()->row();
echo $count->settings_value;
$preacher = array();
$this->db->select('preacher.preacher_id,preacher.first_name,preacher.last_name,preacher.preacher_image,preacher.preacher_logo,preacher.preacher_bio_brief');
$this->db->distinct('preacher.preacher_id');
$this->db->from('preacher');
$this->db->join('sermons', 'sermons.preacher_id=preacher.preacher_id');
$this->db->order_by('preacher.sort_order');
$this->db->limit($count->settings_value);
$query = $this->db->get('', $limit, $offset);
if ($query->num_rows() > 0) {
foreach ($query->result() as $row) {
$preacher[$row->preacher_id]['preacher_id'] = $row->preacher_id;
$preacher[$row->preacher_id]['preacher_name'] = $row->first_name . ' ' . $row->last_name;
$preacher[$row->preacher_id]['preacher_image'] = $row->preacher_image;
$preacher[$row->preacher_id]['preacher_logo'] = $row->preacher_logo;
$preacher[$row->preacher_id]['preacher_bio_brief'] = $row->preacher_bio_brief;
$this->db->select('*');
$this->db->from('sermons');
$this->db->where('preacher_id', $row->preacher_id);
$this->db->order_by('sort_order ');
$sermon_array = array();
$query = $this->db->get();
if ($query->num_rows() > 0) {
foreach ($query->result() as $row1) {
$sermon_array[$row1->sermon_id] ['sermon_image'] = $row1->sermon_image;
$sermon_array[$row1->sermon_id] ['sermon_title'] = $row1->sermon_title;
$sermon_array[$row1->sermon_id] ['audio_file'] = $row1->audio_file;
$sermon_array[$row1->sermon_id] ['sermon_description'] = $row1->sermon_description;
}
}
$preacher[$row->preacher_id]['sermon'] = $sermon_array;
}
return $preacher;
}
return false;
}
Method in controller
function list() {
$paginate_segment = $this->uri->segment(3) ? $this->uri->segment(3) : 0;
$winner_list = $this->sermon_model->viewAllpreachers(0, null);
$config['base_url'] = base_url() . 'sermons/index/';
$config['total_rows'] = ($winner_list) ? count($winner_list) : 0;
$config['per_page'] = 2;
$config['full_tag_open'] = '';
$config['full_tag_close'] = '';
$config['uri_segment'] = 3;
$config['num_links'] = 4;
$config['display_pages'] = TRUE;
$config['first_link'] = 'First';
$config['first_link'] = 'First';
$config['first_tag_open'] = '<div>';
$config['first_tag_close'] = '</div>';
$config['last_link'] = 'Last';
$config['next_link'] = 'Next';
$config['prev_link'] = 'Prev';
$config['cur_tag_close'] = ' | ';
$config['num_tag_close'] = ' | ';
//initialize pagination
$this->pagination->initialize($config);
$this->data['preachers'] = $this->sermon_model->viewAllpreachers($paginate_segment, $config['per_page']);
$this->data['links'] = $this->pagination->create_links();
$this->data['page'] = $this->config->item('APP_template_dir') . 'site/home/sermons_view';
$this->load->vars($this->data);
$this->load->view($this->_container);
}
As stated in the comments, you're using a limit twice and need to combine those methods:
function viewAll($offset=0, $limit=null) {
$this->db->select('settings_value');
$this->db->from('site_settings');
$this->db->where('settings_name', 'preachercount');
$count = $this->db->get()->row();
// now use value of [$count] if [$limit] is null - else use [$limit]
$limit = (is_null($limit)) ? $count : $limit ;
$preacher = array();
$this->db->select('...');
$this->db->distinct('preacher.preacher_id');
$this->db->from('preacher');
$this->db->join('sermons', 'sermons.preacher_id=preacher.preacher_id');
$this->db->order_by('preacher.sort_order');
// then remove the [limit()] call
// $this->db->limit($count->settings_value); <-- NOT NEEDED
$query = $this->db->get('', $limit, $offset);
This effectively allows you to pass a $limit to the method, or use the settings from the db.
I after some help with codeIgniter pagination (fixign a bug).. I can see the number of records and the pagination link in the view but when click on the next link, it does not show the next/previous 10 records. Can someone please help me with this?
I have the following code in my controller
function customerlist_pagination()
{
$search = $this->input->post('search');
$data['title'] = "Customer Clist";
$data['heading'] = "List of customers";
$data['result'] = $this->customers_model->getAllcustomers_pagination($search_para, FALSE, "limit_rows");
$data['num_recs'] = $this->customers_model->getAllcustomers_pagination($search_para, FALSE, "num");
$config['base_url'] = base_url().'index.php/customer/customerlist_pagination/';
$config['total_rows'] = $data['num_recs'];
$config['per_page'] = 10;
$config['uri_segment'] = 3;
$config['next_link'] = 'Next >';
$config['prev_link'] = '< Previous ';
$this->pagination->initialize($config);
$this->load->view('customer_view_table',$data);
}
In the model, I have the following code:
function getAllSeizures_pagination($search_para, $archive_search = FALSE, $result_type)
{
$search_para = $search_para."%";
$selected_fields = "customer.firstName
customer.lastName, customer.address,
customer.city, customer.postcode";
$from = "customer";
$where = "customer.deleted=0 ";
if ($archive_search == TRUE) {
$where .= "AND customer.archived= 1 ";
}else{
$where .= "AND customer.archived= 0 ";
}
$where .= "AND (customer.firstName LIKE '$search_para' OR customer.postcode LIKE '$search_para' OR customer.city LIKE '$search_para')";
$query = $this->db->select($selected_fields, false)
->from($from)
->where($where)
->order_by('customer.idcustomer', 'desc');
if($result_type == "limit_rows")
{
$query = $this->db->limit(10, 0)
->get();
$query = $query->result();
}
if($result_type == "num") {
$query = $this->db->get();
$query = $query->num_rows();
}
return $query;
}
Thanks alot
Regards
Prats
The pagination class passes the offset to you in the uri_segment specified. Since you set it to 3, you should capture that info in the first variable of your controller method, like so:
function customerlist_pagination( $offset )
{
}
Then, when you call your $this->customers_model->getAllcustomers_pagination(), you have to pass it the $offset, so that later on in your code, where you limit your results:
$query = $this->db->limit(10, 0)->get();
you should instead use this $offset to limit your results:
$query = $this->db->limit(10, $offset)->get();