这里是视图部分,在views里面创建了一个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" border="1">
<tr>
<td colspan="3">新闻列表</td>
</tr>
<tr>
<td width="59">序号</td>
<td width="243">标题</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>添加新闻内容</title>
</head>
<body>
<form action="addaction" method="post">
<table width="573" border="1">
<tr>
<td colspan="2" align="center">添加内容</td>
</tr>
<tr>
<td width="92">标题</td>
<td width="465"><input type="text" name="title" /></td>
</tr>
<tr>
<td height="137">内容</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>修改新闻内容</title>
</head>
<body>
<form action="../changeaction/<?php echo $id;?>" method="post">
<table width="573" border="1">
<tr>
<td colspan="2" align="center">修改内容</td>
</tr>
<tr>
<td width="92">标题</td>
<td width="465"><input type="text" value="<?php echo $title;?>" name="title" /></td>
</tr>
<tr>
<td height="137">内容</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>
更多信息请查看IT技术专栏