artice_manage.php:
<?php require('common.php'); islogin();?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<style type="text/css">
<!--
a:link {text-decoration: none; color:#333333;}
a:hover {text-decoration: none;color:#333333;}
a:active {text-decoration: none;color:#333333;}
a:visited {text-decoration: none;color:#333333;}
body {
background-color: #CCCCCC;
}
-->
</style>
</head><div>
<center><font color="#FF0000" size="+2">Manage Artice</font></center>
<div>
<hr />
<table align="center" width="700" height="50" bgcolor="#CCCCCC" cellpadding="4">
<tr>
<td>Id</td>
<td>Title</td>
<td>Type</td>
<td>Date</td>
</tr>
</table>
</div>
<?php
$pagesize=10;
$sql="select a_id from admin_manager_artice";
$count=mysql_num_rows(mysql_query($sql));
$pagecount=ceil($count/$pagesize);
if($_GET["page"])
{
$page=$_GET["page"];
}
else
{
$page=1;
}
if($page>$pagecount)
{
$page=$pagecount;
}
if($page<=0)
{
$page=1;
}
$offset=($page-1)*$pagesize;
$mysql="select * from admin_manager_artice limit $offset,$pagesize";
$result=mysql_query($mysql);?>
<?php while($rs=mysql_fetch_array($result)){?>
<div>
<table align="center" width="700" height="50" bgcolor="#CCCCCC" cellpadding="4">
<tr>
<td width="70"><?php echo $rs[a_id];?></td>
<td width="150"><a href="artice_manage.php?a_id=<?=$rs[a_id];?>" title="<?=$rs[a_title];?>"><?php echo $rs[a_title];?></td>
<td width="150"><?php echo $rs[a_type];?></td>
<td width="100"><?php echo $rs[a_date];?></td>
<td width="50"><input type="checkbox" value="<?=$rs[a_id]?>" name="del" id="del" /></td>
<td><label><a href="manage_post.php?action=artice_delete&&aid=<?=$rs[a_id];?>">Delete</a></label></td>
</tr>
</table>
</div>
<?php } ?>
<hr />
<center>
<span><font color="#FF0000" size="+1">PAGE: </font><a href="?page=1">first </a><a href="?page=<?=($page-1)?>">pre </a><a href="?page=<?=($page+1)?>">next </a><a href="?page=<?=$pagecount?>">least</a></span>
<span><font color="#FF0000" size="+1">EDIT: </font><a href="manage_post.php?action=artice_edit">Edit</a></span>
<label><a href="manage_post.php?action=artice_delete&&aid=<?=$rs[a_id];?>">Delete</a></label> //---->怎样才能让a_id的值传到manage_post.php这个面页进行删除操作。</center>manage_post.php:
<?php
if($_POST['action']=="artice_delete")
{
$aid=$_GET['aid'];
$sql="DELETE a_id FROM admin_manager_artice where a_id='".$aid."'";
mysql_query($sql) or die("query error");
echo "<script>alert('delete success');location.href='artice_manage.php';</script>";
}
?>
<?php require('common.php'); islogin();?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<style type="text/css">
<!--
a:link {text-decoration: none; color:#333333;}
a:hover {text-decoration: none;color:#333333;}
a:active {text-decoration: none;color:#333333;}
a:visited {text-decoration: none;color:#333333;}
body {
background-color: #CCCCCC;
}
-->
</style>
</head><div>
<center><font color="#FF0000" size="+2">Manage Artice</font></center>
<div>
<hr />
<table align="center" width="700" height="50" bgcolor="#CCCCCC" cellpadding="4">
<tr>
<td>Id</td>
<td>Title</td>
<td>Type</td>
<td>Date</td>
</tr>
</table>
</div>
<?php
$pagesize=10;
$sql="select a_id from admin_manager_artice";
$count=mysql_num_rows(mysql_query($sql));
$pagecount=ceil($count/$pagesize);
if($_GET["page"])
{
$page=$_GET["page"];
}
else
{
$page=1;
}
if($page>$pagecount)
{
$page=$pagecount;
}
if($page<=0)
{
$page=1;
}
$offset=($page-1)*$pagesize;
$mysql="select * from admin_manager_artice limit $offset,$pagesize";
$result=mysql_query($mysql);?>
<?php while($rs=mysql_fetch_array($result)){?>
<div>
<table align="center" width="700" height="50" bgcolor="#CCCCCC" cellpadding="4">
<tr>
<td width="70"><?php echo $rs[a_id];?></td>
<td width="150"><a href="artice_manage.php?a_id=<?=$rs[a_id];?>" title="<?=$rs[a_title];?>"><?php echo $rs[a_title];?></td>
<td width="150"><?php echo $rs[a_type];?></td>
<td width="100"><?php echo $rs[a_date];?></td>
<td width="50"><input type="checkbox" value="<?=$rs[a_id]?>" name="del" id="del" /></td>
<td><label><a href="manage_post.php?action=artice_delete&&aid=<?=$rs[a_id];?>">Delete</a></label></td>
</tr>
</table>
</div>
<?php } ?>
<hr />
<center>
<span><font color="#FF0000" size="+1">PAGE: </font><a href="?page=1">first </a><a href="?page=<?=($page-1)?>">pre </a><a href="?page=<?=($page+1)?>">next </a><a href="?page=<?=$pagecount?>">least</a></span>
<span><font color="#FF0000" size="+1">EDIT: </font><a href="manage_post.php?action=artice_edit">Edit</a></span>
<label><a href="manage_post.php?action=artice_delete&&aid=<?=$rs[a_id];?>">Delete</a></label> //---->怎样才能让a_id的值传到manage_post.php这个面页进行删除操作。</center>manage_post.php:
<?php
if($_POST['action']=="artice_delete")
{
$aid=$_GET['aid'];
$sql="DELETE a_id FROM admin_manager_artice where a_id='".$aid."'";
mysql_query($sql) or die("query error");
echo "<script>alert('delete success');location.href='artice_manage.php';</script>";
}
?>
=》if($_GET['action']=="artice_delete")
换成以下句子:<a href="manage_post.php?action=artice_delete&aid=<?php echo $rs['a_id'];?>">
建议楼主从开始就要养成一个好的习惯,<?php echo $--;?>与<?=$--?>,这两个输出结果一样,但最好按前者写,因为有时候配置中没有设置短标签的话容易出错。第二,<?php echo $rs["aa"];?>与<?php echo $rs[];?>虽然就一个 引号,但是对于网页的执行速度影响很大