Welcome Guest, Not a member yet? Register   Sign In
pagination help
#9

[eluser]sasori[/eluser]
here's my model
Code:
class Stock_model extends Model
{

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

    function getStocks()
    {
      $data = array();
      $data = $this->db->get('stocks');
      return $data;
    }

        function putData($txt)
    {
        $handle = file_get_contents($txt);
        $var_array = explode(";",$handle);
        $a = array_chunk($var_array,4);

            for($i=0;$i<sizeof($a);$i++)
            {
                if(isset($a[$i][1]))
                    $a[$i][1] = preg_replace("/\s\%/","%",$a[$i][1]);

                if(isset($a[$i][0]))
                    $data['compcode'] = $a[$i][0];

                if(isset($a[$i][1]))
                    $data['pricepercent'] = $a[$i][1];

                if(isset($a[$i][2]))
                    $data['compname'] = $a[$i][2];

                if(isset($a[$i][3]))
                    $data['volume'] = $a[$i][3];

                #print_r($data);
                $this->db->insert('stocks',$data);
            }

        return $this->db->affected_rows();
    }

}

here's the controller function for the supposed to be pagination thing
Code:
function index()
    {
      $data['base'] = $this->config->item('base_url');
      $data['css'] = $this->config->item('css');
      $this->load->model('stock_model');
      $stocks = $this->stock_model->getStocks();

      $this->load->library('pagination');
      $config['base_url'] = 'http://myapp/welcome/stocks/';
      $config['total_rows'] = '20';
      $config['per_page'] = '10';
      $this->pagination->initialize($config);
      $data['pagination'] = $this->pagination->create_links();
      $this->load->view('stocks_view',$data);
    }


Messages In This Thread
pagination help - by El Forum - 01-19-2010, 09:36 PM
pagination help - by El Forum - 01-19-2010, 09:55 PM
pagination help - by El Forum - 01-19-2010, 10:00 PM
pagination help - by El Forum - 01-19-2010, 10:37 PM
pagination help - by El Forum - 01-19-2010, 10:44 PM
pagination help - by El Forum - 01-19-2010, 11:15 PM
pagination help - by El Forum - 01-19-2010, 11:24 PM
pagination help - by El Forum - 01-19-2010, 11:35 PM
pagination help - by El Forum - 01-19-2010, 11:37 PM
pagination help - by El Forum - 01-20-2010, 12:08 AM
pagination help - by El Forum - 01-20-2010, 12:09 AM
pagination help - by El Forum - 01-20-2010, 12:22 AM
pagination help - by El Forum - 01-20-2010, 12:27 AM
pagination help - by El Forum - 01-20-2010, 12:28 AM
pagination help - by El Forum - 01-20-2010, 12:33 AM
pagination help - by El Forum - 01-20-2010, 12:58 AM
pagination help - by El Forum - 01-20-2010, 01:02 AM
pagination help - by El Forum - 01-20-2010, 01:09 AM
pagination help - by El Forum - 01-20-2010, 01:16 AM
pagination help - by El Forum - 01-20-2010, 03:05 AM



Theme © iAndrew 2016 - Forum software by © MyBB