1
我使用PHP codeigniter爲我的網站。在這裏,我有一些很多(模型),我想按時間,類別等排序(每種類型我有鏈接在頁面上)。現在我有下一個代碼,但它不工作(頁面不排序)。這裏是我的控制器:Codeigniter排序頁面內容
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Gamezone extends CI_Controller {
public function index()
{
if (sizeof($_GET) > 0) {
$sortType = $_GET['sortType'];
} else {
$sortType = 0;
}
$this->lang->load('auth', $this->language_lib->detect());
$data['aukcion'] = 'Gamezone';
$this->load->model('auctions_model');
$data['auct'] = $this->auctions_model->game_zones($sortType);
$this->load->view('/common/header_view',$data);
$this->load->view('gamezone_view',$data);
$this->load->view('/common/footer_view',$data);
}
}
下面是從我的模型方法game_zones($ sortType):
public function game_zones($type) {
switch ($type) {
case 1:
$this->db->order_by('start_time', 'desc');
break;
case 2:
$this->db->order_by('category', 'desc');
break;
case 3:
$this->db->order_by('genre', 'desc');
break;
default:
break;
}
$query = $this->db->get_where('ay_lots', array('game_zone' => 1));
$result = $query->result();
return $result;
}
我做Ajax請求指數提供的排序是這樣的:
function sortAuctions(sortType) {
$.ajax({
type: 'GET',
url: '/gamezone/index',
data: { 'sortType' : sortType },
success: function(data) {
window.location = '/gamezone';
}
});
}
什麼時我做錯了?