Records and array in the view |
[eluser]henry178[/eluser]
Hi, i have this Model: class Pagination1_model extends CI_Model { function __construct() { parent::__construct(); } public function getAll_cabina($num, $offset) { $data = $this->db->get('tab_anagrafica', $num, $offset); if($data->num_rows()>0){ return $data->result_array(); } else{ return false; } $data->free_result(); } } The control is this: $this->load->model('pagination1_model'); $data['rows'] = $this->pagination1_model->getAll_cabina($config['per_page'], $this->uri->segment(2)); $this->load->view('template1/prova',$data); In the view.... how do I see on the array?
[eluser]InsiteFX[/eluser]
Code: public function getAll_cabina($num, $offset) Your view code would be something like this, hard to tell without knowing your fields in the table! Code: <?php foreach($row as $rows):?> InsiteFX
[eluser]henry178[/eluser]
[quote author="InsiteFX" date="1301514980"] Code: public function getAll_cabina($num, $offset) Your view code would be something like this, hard to tell without knowing your fields in the table! Code: <?php foreach($row as $rows):?> InsiteFX[/quote] Perfect! :-)
[eluser]henry178[/eluser]
in my routes.php: $route['en'] = "home/en"; $route['en/beb'] = "home/en/"; my controller: function en() { $this->load->library('pagination'); $config['first_link'] = 'Primo'; $config['next_link'] = 'avanti'; $config['prev_link'] = 'indietro'; $config['last_link'] = 'Ultimo'; $config['base_url'] = '/en'; $config['total_rows'] = $this->db->count_all('tab_anagrafica'); $config['per_page'] = '10'; $config['full_tag_open'] = '<div id="pagination">Pagine: '; $config['full_tag_close'] = '</div>'; $this->pagination->initialize($config); $this->load->model('pagination1_model'); $data['rows'] = $this->pagination1_model->getAll_cabina($config['per_page'], $this->uri->segment(1)); $this->load->view('template1/prova',$data); } in my view: <?php echo $this->pagination->create_links(); ?> <record> <?php echo $this->pagination->create_links(); ?> but if i click in the pagination i receive this url: http://localhost/en&per_page=10 ERROR 404 I was expecting: http://localhost/en?per_page=10 why there isn't question mark in the url? and why the records do not flow?
[eluser]InsiteFX[/eluser]
You must have this set in your application/config/config.php Code: $config['page_query_string'] = TRUE; InsiteFX
[eluser]henry178[/eluser]
[quote author="InsiteFX" date="1301525094"]You must have this set in your application/config/config.php Code: $config['page_query_string'] = TRUE; InsiteFX[/quote] never change! The url is the same: http://localhost/en&per_page=10 404 Page Not Found why this error?
[eluser]henry178[/eluser]
in the Model: public function getAll_cabina($num, $offset) { echo "num: "; echo $num; echo "<br>offset: "; echo $offset; echo "<br>"; $data = $this->db->get('tab_anagrafica', $num, $offset); if($data->num_rows()>0){ return $data->result_array(); } else{ return false; } $data->free_result(); } var offset is ever empty....
[eluser]InsiteFX[/eluser]
From the looks of it, it looks like your language is adding the & or your routes.php what is this set to in application/config/config.php ? Code: $config['uri_protocol'] = 'AUTO'; InsiteFX
[eluser]henry178[/eluser]
[quote author="InsiteFX" date="1301594927"]From the looks of it, it looks like your language is adding the & or your routes.php what is this set to in application/config/config.php ? Code: $config['uri_protocol'] = 'AUTO'; InsiteFX[/quote] this is my: $config['uri_protocol'] = 'AUTO'; the same.... My routes: $route['default_controller'] = "home/en"; $route['404_override'] = ''; // URI like '/en/about' -> use controller 'about' //$route['^fr/(.+)$'] = "$1"; //$route['^en/(.+)$'] = "$1"; // '/en' and '/fr' URIs -> use default controller //$route['^fr$'] = $route['default_controller']; //$route['^en$'] = $route['default_controller']; $route['en'] = "home/en"; $route['en/agriturismi'] = "home/en/"; $route['en/agriturismi/([a-z]+)'] = "home/en/$1";
[eluser]henry178[/eluser]
if change this: $config['allow_get_array'] = TRUE; $config['enable_query_strings'] = FALSE; this is the result url http://localhost/en/10 404 Page Not Found :-( |
Welcome Guest, Not a member yet? Register Sign In |