內(nèi)容管理demo之View-CI(codeigniter)PHP框架

字號:


    這里是視圖部分,在views里面創(chuàng)建了一個(gè)news文件夾,并有如下文件。
    index.html
    add.html
    change.html
    代碼分別是
    index.html
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>新聞列表頁面</title>
    </head>
    <body>
    <table width="408">
    <tr>
    <td colspan="3">新聞列表</td>
    </tr>
    <tr>
    <td width="59">序號</td>
    <td width="243">標(biāo)題</td>
    <td width="84">操作</td>
    </tr>
    <?php
    foreach($news['list'] as $rows){?>
    <tr>
    <td width="59"><?php echo $rows['id'];?></td>
    <td width="243"><?php echo $rows['title'];?></td>
    <td width="84"><a href="../change/<?php echo $rows['id'];?>">修改</a><a href="../del/<?php echo $rows['id'];?>">刪除</a></td>
    </tr>
    <?php }
    ?>
    <tr>
    <td colspan="3">
    <a href="1">首頁</a>
    <a href="<?php echo $news['pageup'];?>">上頁</a>
    <a href="<?php echo $news['pagedown'];?>">下頁</a>
    <a href="<?php echo $news['pagemax'];?>">末頁</a>
    </td>
    </tr>
    </table>
    </body>
    </html>
    add.html 代碼 是
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>添加新聞內(nèi)容</title>
    </head>
    <body>
    <form action="addaction" method="post">
    <table width="573">
    <tr>
    <td colspan="2">添加內(nèi)容</td>
    </tr>
    <tr>
    <td width="92">標(biāo)題</td>
    <td width="465"><input type="text" name="title" /></td>
    </tr>
    <tr>
    <td height="137">內(nèi)容</td>
    <td><textarea name="content" rows="10" cols="50"></textarea></td>
    </tr>
    <tr>
    <td colspan="2">
    <input type="submit" value="確定添加" />
    </td>
    </tr>
    </table>
    </form>
    </body>
    </html>
    change.html代碼是
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>修改新聞內(nèi)容</title>
    </head>
    <body>
    <form action="../changeaction/<?php echo $id;?>" method="post">
    <table width="573">
    <tr>
    <td colspan="2">修改內(nèi)容</td>
    </tr>
    <tr>
    <td width="92">標(biāo)題</td>
    <td width="465"><input type="text" value="<?php echo $title;?>" name="title" /></td>
    </tr>
    <tr>
    <td height="137">內(nèi)容</td>
    <td><textarea name="content" rows="10" cols="50"><?php echo $content;?></textarea></td>
    </tr>
    <tr>
    <td colspan="2">
    <input type="submit" value="確定修改" />
    </td>
    </tr>
    </table>
    </form>
    </body>
    </html>