codeigniter分页链接重定向到注销页面

时间:2013-05-16 13:21:50

标签: php codeigniter

我是codeigniter的新手。我正在使用分页。分页链接显示正常,但是当我点击任何链接时,我就会退出。 这是我的代码,请检查是否需要更正

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Packages extends CI_Controller {

function __construct() {
    parent::__construct();

    $this->load->model('admin_packages');
    $this->load->model('common_model'); 
    $this->load->helper(array('form', 'url'));      
    $this->load->library('form_validation');
    $this->load->library('pagination');
    $this->load->library('common');

}


function packages()
{

if(!$this->session->userdata('userid'))
    redirect('index.php/users/login'); 
    $ofset=0;
$config['base_url']='http://localhost/index.php/vehicles/packages/';            
$config['total_rows']=$this>common_model>get_countt('packages_purchased','user_id',$this->session->userdata('userid'));
        $config['per_page'] = '10';
        $config['use_page_numbers'] = TRUE;
        $config['full_tag_open'] = '<p align="center">';
        $config['full_tag_close'] = '</p>';
        $this->pagination->initialize($config);  
        if($this->uri->segment(3))
        $ofset=($this->uri->segment(3)-1)*$config['per_page'];

    $uid=$this->session->userdata('userid');
    $bal=$this->vehicle->available_balance($uid);
    $arr['balanc']=$bal->mots;
    $arr['dtee']=$bal->dt;
    $arr['pack']=$this->common_model->get_alldetails('packages','status',1);
$arr['det']=$this->vehicle->purchased_packages($this->session->userdata('userid'),$ofset,$config['per_page']);

   $arr['page_title']='Reminder | Automated TEXT and Email Alerts for Garage Owners';   
   $this->breadcrumb->append_crumb("My Account<span>&nbsp;&#8250;&nbsp;<span>Packages", '/page');
    $this->load->template('vehicles/purchased_packages',$arr);
}

1 个答案:

答案 0 :(得分:0)

$config['base_url'] = base_url().'vehicles/packages'

忽略index.php

如果它将您重定向到注销,您确定正在验证当前用户的会话是否正常工作?

您是否尝试使用this->db->last_query()来显示查询的外观? 因为这段代码在这里

if($this->uri->segment(3))
$ofset=($this->uri->segment(3)-1)*$config['per_page'];

将为您提供90

的偏移量 模型上的

$this->vehicle->purchased_packages添加

$this->db->last_query();
die();

在返回之前,这将打印出您刚刚提出的查询,并且您可以看到您是否正在获得所需的数据。