756425616 发表于 2010-8-6 16:18:53

测试后台程序教程。。。。

视图层
frame_view.php
<html>
<head>
<title>新闻后台</title>
</head>
<frameset cols="15%,*">
<frame src='frame/left'>
<frame src='frame/right'name='main'>
</frameset>
</html>

left.php
<html>
<head>
<title>新闻</title>
</head>
<body>
<center>
<a href='deal'target='main'>公司新闻</a>
</center>
</body>
</html>

right.php欢迎光临modify_view.php
<html>
<head>
<meta http-equiv="content-Type" content="text/html; charset=gb2312">
</head>
<body>
        <form method="post" name="myform" action="update">
                <table width="100%" border="0" cellspacing="1" cellpadding="0">
                  <tr bgcolor="#ECF5FF">
                  <td width="15%" height="25"> 新闻标题:<input name=title></td>                  
                  </tr><br>
                  <tr bgcolor="#ECF5FF">
                  <td height="25" >新闻内容:</td>
                  </tr><br>
                  <tr bgcolor="#ECF5FF">
                  <td ><textarea name="content" style="display:none" rows=20 cols=50></textarea>
                      <iframe ID="eWebEditor1" src="http://localhost/CI/eWebEditor/ewebeditor.php?id=content&style=standard" frameborder="0" scrolling="no" width="560" HEIGHT="450"></iframe>
                  </td>
                  </tr><br>
                  <tr bgcolor="#ECF5FF">
                  <td height="25" >
                        <input name="submit" type="submit" value="确定">
                        &nbsp;
                        <input name="reset" type="reset" value="重置">
                  </td>
                  </tr>
                </table>
          </form>
</body>
</html>

控制层
frame.php

<?php
        class Frame extends Controller
        {
                function __construct()
                {
                        parent::Controller();
                }
                function index()
                {
                        $this->load->helper('url');                       
                        $this->load->view('frame_view');
                }
                function left()
                {
                        $this->load->view('left');
                }
                function right()
                {
                        $this->load->view('right');
                }
                function deal()
                {
                        $this->load->database();
                        $this->load->model('frame_model');
                        $this->frame_model->sel();
                }
                function modify()
                {
                        $this->load->view('modify_view');
                }
                function update()
                {
                        $this->load->database();
                        $this->load->model('frame_model');
                        $this->frame_model->update();
                }
        }
?>

模型层
frame_model.php
<?php
        class frame_model extends Model
        {
                function __construct()
                {
                        parent::Model();
                        $this->load->helper('url');       
                }
                function sel()
                {
                        $query=$this->db->get('ci2');
                        foreach($query->result() as $row)
                        {
                                echo $row->title."&nbsp;&nbsp;".anchor('frame/modify','修改')."<br>";
                        }
                }
                function update()
                {
                        $data=$this->input->post('title',true);
                        $this->db->query("update ci2 set title='".$data."'");
                }
        }
?>

感想:完了,enjoy,功能大体就是调用个编辑器,可以更新标题,内容的没写,原理都一样的。。实在没什么好讲的。。就这样吧!!!
页: [1]
查看完整版本: 测试后台程序教程。。。。