求大牛帮忙添加几句,实现在“更新修改”后面实现删除功能
<?php
require 'config/dbconnection.php';
$userid=$_COOKIE['userid'];
if($userid!=""&&$userid!=NULL&&$userid!=0){
//执行查询操作
$getstrselsql="SELECT * FROM `masterinfo`.`clientcollection` where memberid=$userid";
$getquery = db_query($getstrselsql);
while ($clien=mysql_fetch_array($getquery)){
//echo $clien['forum_name'];
}
}else{
echo "<script>alert('请先登录,再查看文档');window.location.href='memberlogin.php';</script>";
}if($_SERVER['REQUEST_METHOD']=="POST") {
}
?>
<!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>所有下载</title>
<link rel="stylesheet" type="text/css" href="css/registercommon.css?XWa" />
<link rel="stylesheet" type="text/css" href="css/gre.css" />
<script type="text/javascript" language="javascript" src="script/provinces.js" ></script>
<script src="script/register.js?XWa" type="text/javascript"></script>
<script src="script/common.js"></script>
<script src="script/tool.js"></script>
</head>
<body>
<form action="" method="post" >
<div class="ptm wp cl" id="ct"><div class="mn"><div id="main_message" class="bm"><div id="main_hnav" class="bm_h bbs"><span class="y">
<a class="xi2" href="index.php">主页</a> <a class="xi2" onclick="SetCookie('userid','')" href="memberlogin.php">退出</a>
</span><h3 class="xs2" id="layer_reginfo_t">
所有下载</h3>
</div><div class="bm_c" id="layer_reg"><?php $isstrselsql="SELECT * FROM `masterinfo`.`clientcollection` where memberid=$userid order by date desc LIMIT 0,20";
$isgetquery = db_query($isstrselsql);
if ($clien=mysql_fetch_array($isgetquery)){?>
<div class="mtw">
<div id="reginfo_a">
<div class="rfm">
<table>
<tbody><tr>
<th style="text-align:center"><label for="ZD5p32">论坛名称</label></th>
<th style="text-align:center"><label for="ZD5p32">论坛地址</label></th>
<th style="text-align:center"><label for="ZD5p32">discuz版本</label></th>
<th style="text-align:center"><label for="ZD5p32">生成日期</label></th>
<th style="text-align:center"><label for="ZD5p32">更新修改</label></th>
<th style="text-align:center"><label for="ZD5p32">删除</label></th>
</tr>
</tbody></table>
</div>
<?php
if($userid!=""&&$userid!=NULL&&$userid!=0){
//设定每一页显示的记录数
$pagesize=10;
//取得记录总数$rs,计算总页数用
$rowCount;
$rowCountSql="SELECT count(*) FROM `masterinfo`.`clientcollection` where memberid=$userid";
$rowCount=mysql_query($rowCountSql);
$rw=mysql_fetch_row($rowCount);
$numrows= $rw[0];//计算总页数$pages=intval($numrows/$pagesize);
if ($numrows%$pagesize){
$pages++;}
//设置页数
if (isset($_GET['page'])){
$page=intval($_GET['page']);
}
else{
//设置为第一页
$page=1;
}$offset=$pagesize*($page - 1);
//读取指定记录数
//执行查询操作
$getstrselsql="SELECT * FROM `masterinfo`.`clientcollection` where memberid=$userid order by date desc limit $offset,$pagesize";
$getquery = db_query($getstrselsql);
while ($clien=mysql_fetch_array($getquery)){
$cid=$clien['cid'];
$forumname = $clien['forum_name'];
$forumurl=$clien['forum_url'];
$version=$clien['version'];
$dowonfilename=$clien['dowonfilename'];
$date=date('Y-m-d H:i', $clien['date']);
//执行删除操作
?>
<div class="rfm" >
<table >
<tbody >
<tr>
<th style="text-align:center"><?php echo $forumname?></th>
<th style="text-align:center"><?php echo $forumurl?></th>
<th style="text-align:center"><?php echo $version?></th>
<th style="text-align:center"><?php echo $date?></th>
<th style="text-align:center"><a href="clientcollection.php?cid=<?php echo $cid?>">更新修改</a></th>
</tr>
</tbody></table>
</div>
<?php
require 'config/dbconnection.php';
$userid=$_COOKIE['userid'];
if($userid!=""&&$userid!=NULL&&$userid!=0){
//执行查询操作
$getstrselsql="SELECT * FROM `masterinfo`.`clientcollection` where memberid=$userid";
$getquery = db_query($getstrselsql);
while ($clien=mysql_fetch_array($getquery)){
//echo $clien['forum_name'];
}
}else{
echo "<script>alert('请先登录,再查看文档');window.location.href='memberlogin.php';</script>";
}if($_SERVER['REQUEST_METHOD']=="POST") {
}
?>
<!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>所有下载</title>
<link rel="stylesheet" type="text/css" href="css/registercommon.css?XWa" />
<link rel="stylesheet" type="text/css" href="css/gre.css" />
<script type="text/javascript" language="javascript" src="script/provinces.js" ></script>
<script src="script/register.js?XWa" type="text/javascript"></script>
<script src="script/common.js"></script>
<script src="script/tool.js"></script>
</head>
<body>
<form action="" method="post" >
<div class="ptm wp cl" id="ct"><div class="mn"><div id="main_message" class="bm"><div id="main_hnav" class="bm_h bbs"><span class="y">
<a class="xi2" href="index.php">主页</a> <a class="xi2" onclick="SetCookie('userid','')" href="memberlogin.php">退出</a>
</span><h3 class="xs2" id="layer_reginfo_t">
所有下载</h3>
</div><div class="bm_c" id="layer_reg"><?php $isstrselsql="SELECT * FROM `masterinfo`.`clientcollection` where memberid=$userid order by date desc LIMIT 0,20";
$isgetquery = db_query($isstrselsql);
if ($clien=mysql_fetch_array($isgetquery)){?>
<div class="mtw">
<div id="reginfo_a">
<div class="rfm">
<table>
<tbody><tr>
<th style="text-align:center"><label for="ZD5p32">论坛名称</label></th>
<th style="text-align:center"><label for="ZD5p32">论坛地址</label></th>
<th style="text-align:center"><label for="ZD5p32">discuz版本</label></th>
<th style="text-align:center"><label for="ZD5p32">生成日期</label></th>
<th style="text-align:center"><label for="ZD5p32">更新修改</label></th>
<th style="text-align:center"><label for="ZD5p32">删除</label></th>
</tr>
</tbody></table>
</div>
<?php
if($userid!=""&&$userid!=NULL&&$userid!=0){
//设定每一页显示的记录数
$pagesize=10;
//取得记录总数$rs,计算总页数用
$rowCount;
$rowCountSql="SELECT count(*) FROM `masterinfo`.`clientcollection` where memberid=$userid";
$rowCount=mysql_query($rowCountSql);
$rw=mysql_fetch_row($rowCount);
$numrows= $rw[0];//计算总页数$pages=intval($numrows/$pagesize);
if ($numrows%$pagesize){
$pages++;}
//设置页数
if (isset($_GET['page'])){
$page=intval($_GET['page']);
}
else{
//设置为第一页
$page=1;
}$offset=$pagesize*($page - 1);
//读取指定记录数
//执行查询操作
$getstrselsql="SELECT * FROM `masterinfo`.`clientcollection` where memberid=$userid order by date desc limit $offset,$pagesize";
$getquery = db_query($getstrselsql);
while ($clien=mysql_fetch_array($getquery)){
$cid=$clien['cid'];
$forumname = $clien['forum_name'];
$forumurl=$clien['forum_url'];
$version=$clien['version'];
$dowonfilename=$clien['dowonfilename'];
$date=date('Y-m-d H:i', $clien['date']);
//执行删除操作
?>
<div class="rfm" >
<table >
<tbody >
<tr>
<th style="text-align:center"><?php echo $forumname?></th>
<th style="text-align:center"><?php echo $forumurl?></th>
<th style="text-align:center"><?php echo $version?></th>
<th style="text-align:center"><?php echo $date?></th>
<th style="text-align:center"><a href="clientcollection.php?cid=<?php echo $cid?>">更新修改</a></th>
</tr>
</tbody></table>
</div>
if($_GET[del]){
mysql_query("delete from table where id=".$_GET[del]);
echo "删除成功";
}
<th style="text-align:center"><a href="clientcollection.php?cid=<?php echo $cid?>">更新修改</a></th>$id = isset($_GET['cid'])?:(int)$_GET['cid']:"";
if(!empty($id)){
mysql_query("delete from table where id=".$id);
}
else{
echo "id invalid,please check~~";
exit;
}
<th style="text-align:center"><a href="clientcollection.php?cid=<?php echo $cid?>">更新修改</a></th>if(isset($_GET['cid'])){
$id = (int)$_GET['cid'];
if(!empty($id)){
mysql_query("delete from table where id=".$id);
}
else{
echo "id invalid,please check~~";
exit;
}
}
mysql_query("delete from `clientcollection` where id=".$_GET[del]);
echo "删除成功";
}
<th style="text-align:center"><input type="button" value="删除" onclick="del=<?php echo $cid?>">删除</a></th> 如果我这样 能点击按钮把显示的语句执行删除吗
这样不能,你的onclick事件不会跳转到删除的页面。
<input type="button" value="删除" onclick="window.location.href='?del=<?php echo $cid?>';">新页面:
<input type="button" value="删除" onclick="window.location.href='其他的页面?del=<?php echo $cid?>';">然后加上上面删除代码。
你得用:
<th style="text-align:center"><input type="button" value="删除" onclick="window.location.href='clientcollection.php?del=<?php echo $cid?>';"></th>