一、文章刪除程序
<?php
require_once('../connect.php');
$id = $_GET['id'];
$deletesql = "delete from article where id=$id";
if(mysql_query($deletesql)){
echo "<script>alert('刪除文章成功');window.location.href='article.manage.php';</script>";
}else{
echo "<script>alert('刪除文章失敗');window.location.href='article.manage.php';</script>";
}
?>
二、文章管理界面
<?php
require_once('../connect.php');
$sql = "select * from article order by dateline desc";
$query = mysql_query($sql);
if($query&&mysql_num_rows($query)){
while($row =mysql_fetch_assoc($query)){
$data[] = $row;
}
}else{
$data = array();
}
?>
<html >
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>無標題文檔</title>
<style type="text/css">
body {
margin-left: 0px;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
}
</style>
</head>
<body>
<table width="100%" height="520" border="0" cellpadding="8" cellspacing="1" bgcolor="#000000">
<tr>
<td height="89" colspan="2" bgcolor="#FFFF99"><strong>後臺管理系統</strong></td>
</tr>
<tr>
<td width="156" height="287" align="left" valign="top" bgcolor="#FFFF99"><p><a href="article.add.php">發佈文章</a></p>
<p><a href="article.manage.php">管理文章</a></p></td>
<td width="837" valign="top" bgcolor="#FFFFFF"><table width="743" border="0" cellpadding="8" cellspacing="1" bgcolor="#000000">
<tr>
<td colspan="3" align="center" bgcolor="#FFFFFF">文章管理列表</td>
</tr>
<tr>
<td width="37" bgcolor="#FFFFFF">編號</td>
<td width="572" bgcolor="#FFFFFF">標題</td>
<td width="82" bgcolor="#FFFFFF">操作</td>
</tr>
<?php
if(!empty($data)){
foreach($data as $value){
?>
<tr>
<td bgcolor="#FFFFFF"> <?php echo $value['id']?></td>
<td bgcolor="#FFFFFF"> <?php echo $value['title']?></td>
<td bgcolor="#FFFFFF"><a href="article.del.handel.php?id=<?php echo $value['id']?>">刪除</a> <a href="article.modify.php?id=<?php echo $value['id']?>">修改</a></td>
</tr>
<?php
}
}
?>
</table></td>
</tr>
</table>
</body>
</html>