|
楼主 |
发表于 2010-5-23 13:23:03
|
显示全部楼层
视图
<?php
/*
控制器程序
*/
class Login extends Controller
{
function Login()
{
parent::Controller();
}
//构造
function index_view()
{
$this->load->view('index');
}
//成功页面的
function show()
{
$this->load->model('index_model');
$this->index_model->inter();
$this->load->view('chenggong');
//$this->index_model->select();
}
function getdata()
{
$this->load->model('index_model');
$data=$this->index_model->select();
echo $data;
$this->load->view('chakan',$data);
}
}
?>
模型
<?php
class Index_model extends Model
{
function Index_model()
{
parent::Model();
}
function inter()
{
$this->load->database();
$title=$_POST['title'];
$message=$_POST['message'];
$this->db->query("INSERT INTO `book`.`message` (`id` ,`title` ,`message`) VALUES ('NULL' , '$title', '$message')");
}
//查询
function select()
{
$this->load->database();
$query=$this->db->query("select * from message");
return $query->result();
}
}
?>
视图代码
<?php foreach($data as $row):?>
title<p><?php echo $row->title;?></p>
<br>
message<br>
<p><?php echo $row->message;?></p>
<hr>
<?php endforeach;?> |
|