<?php
class Test extends CI_Controller {
var $aaa='0'; //这个是我想要用的变量
function __construct()
{
parent::__construct();
}
function index(){
$this->load->helper('form');
$data['title'] = "Project Test.";
$data['headline'] = "Welcome! Please type your ID and select your location first.";
$this->load->vars($data);
$this->load->view('index');
}
function saveloc(){
$this->load->helper('url');
$this->load->model('Mtest','',TRUE);
$this->Mtest->addinfo();
$service=$this->input->post('service');
$this->aaa=$this->input->post('location'); //更改aaa的值,这个我确认过,aaa的值是更改成功的。
$data['current']=$this->input->post('id');
if($service=='1'){
$this->load->helper('form');
$data['title'] = "Transportation";
$data['headline'] = "Please select the traffic situation of your location.";
$this->load->vars($data);
$this->load->view('trans');
}elseif ($service=='2'){
$this->load->helper('form');
$data['title'] = "Food";
$data['headline'] = "How is the food of your location?";
$this->load->vars($data);
$this->load->view('food');
}else{
$this->load->helper('form');
$data['title'] = "Price";
$data['headline'] = "Is there any special price at your location?";
$this->load->vars($data);
$this->load->view('price');
}
}
function updatetrans(){
$this->load->helper('url');
$this->load->model('Mtest','',TRUE);
$this->db->where('location',$this->aaa); //调用aaa的值,可这里aaa又变回0了
$this->Mtest->updatetrans();
redirect('test/thanks','refresh');
}
function updatefood(){
$this->load->helper('url');
$this->load->model('Mtest','',TRUE);
$this->Mtest->updatefood();
redirect('test/thanks','refresh');
}
function updateprice(){
$this->load->helper('url');
$this->load->model('Mtest','',TRUE);
$this->Mtest->updateprice();
redirect('test/thanks','refresh');
}
function thanks(){
echo "<h1>Thank you !</h1>";
}
}
?>