<?php
if(!defined('BASEPATH')) exit("No direct script access allowed");
class page_controller extends CI_Controller
{
public function __construct()
{
parent::__construct();
$this->load->model('page_model');
}
public function contact_info()
{
$config = array();
$config["base_url"] = base_url() . "index.php/page_controller/contact_info";
$total_row = $this->page_model->record_count();
$config["total_rows"] = $total_row;
$config["per_page"] = 1;
$config["use_page_numbers"] = TRUE;
$config["num_links"] = $total_row;
$config["cur_tag_open"] = ' <a class="current">';
$config["cur_tag_close"] = '</a>';
$config["next_link"] = 'Next';
$config["prev_link"] = 'Previous';
$this->pagination->initialize($config);
if($this->uri->segment(3))
{
$page = ($this->uri->segment(3));
}
else
{
$page = 1;
}
$data["results"] = $this->page_model->fetch_data($config["per_page"], $page);
$str_links = $this->pagination->create_links();
$data["links"] = explode(' ', $str_links);
$this->load->view('page_view', $data);
}
}
?>
答案 0 :(得分:0)
您可以使用如下:
if (is_array($values) || is_object($values))
{
foreach ($values as $value)
{
...
}
}