Welcome Guest, Not a member yet? Register   Sign In
Help! with pagination!!
#1

[eluser]Unknown[/eluser]
In controller I have this function which listing data from data base and also contains pagination. when I am removing the pagination code its working fine.

Code:
public function makeManagement($passed_data=NULL)
    {
          $data = array();
          if($passed_data!=NULL)
          $data =(array)$passed_data;
        
          $this->load->library('pagination');
          $query = $this->db->get('tbl_make');
          $a = $query->num_rows();
          $config['base_url'] = base_url().'index.php/admin/makeManagement/';
          $config['total_rows'] = $a;
          $config['per_page'] = '10';
          $config['uri_segment'] = 3;
          $config['full_tag_open'] = '<p>';
          $config['full_tag_close'] = '</p>';
          $this->pagination->initialize($config);
          $this->load->model('admin_model');
           [color=red]$data['makes'] = $this->admin_model->get_make($config['per_page'],$this->uri->segment(3));
          $this->load->view('make_management', $data);[/color]

    }

when I am calling this above function from another function that is saving data to data base then its fine, Here is the add function in controller.


Code:
public function addMakeProcess()
    {
        if(isset($_POST['addmake']) && $_POST['make_title']!="")
        {
            $this->load->model('admin_model');
            unset($_POST['addmake']);
            if($this->admin_model->insert_make($_POST))
            {
                $data['conf'] = "Make added sucessfully.";
                $this->makeManagement($data);
            }
            else
            {
                $data['error'] = "Unable to add new make, please try again.";
                $this->addMakeForm($data);
            }            
        }
        else
        {
            $data['error'] = "Invalid data, please make sure you have made proper entries.";
            $this->makeManagement($data);
        }        
    }

but when I call function "makeManagement($data)" (the first one) from another function namely deleteMake(); then I get an error that is:

A PHP Error was encountered
Severity: Warning
Message: Invalid argument supplied for foreach()
Filename: views/make_management.php
Line Number: 49

Here is the deleteMake() function code:

Code:
public function deleteMake($make_id=NULL)
    {
        if($make_id != NULL)
        {
          $this->load->model('admin_model');
          if($this->admin_model->remove_make($make_id))
          {
              $data['conf'] = "Make deleted sucessfully.";
             [color=red] $this->makeManagement($data);[/color]          
          }
          else
          {
              $data['error'] = "Unable to delete make, please try again.";
              $this->makeManagement($data);
          }
        }
        else
        {
            $data['error'] = "Invalid data, please make sure you have made proper entries.";
            $this->makeManagement($data);
        }
    }

Here is the model code for deleting:

Code:
function remove_make($id)
    {
        try
        {
            $this->db->where('make_id',$id);
            $this->db->delete('tbl_make');
            return true;
        }
        catch(Exception $e)
        {
            return false;
        }
    }


Here is the model code for lsitng recodrs:

Code:
function get_make($perPage, $uri)
    {
          $this->db->order_by('make_id','asc');
          $query = $this->db->get('tbl_make', $perPage, $uri);
          if($query->num_rows() > 0)
          return $query->result_array();
          else
          return false;
    }


What is wrong with this please help I am really stuck with this.

Thanks in advance


Messages In This Thread
Help! with pagination!! - by El Forum - 07-15-2011, 05:40 AM
Help! with pagination!! - by El Forum - 07-16-2011, 03:54 AM
Help! with pagination!! - by El Forum - 07-20-2011, 08:24 AM



Theme © iAndrew 2016 - Forum software by © MyBB