这是我帖子置顶的代码
bbs_tzzd.php
<body>
<form id="form1" name="form1" method="post" action="bbs_update_tzzd.php?update_id=<?php echo $row[lt_send_id];?>">
<table width="700" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td height="32" background="images/right_line.gif"> 您现在的位置:校园馨浪网站后台管理系统</td>
</tr>
<tr>
<td height="32" background="images/right_top.gif"> </td>
</tr>
<tr>
<td height="488" align="center" valign="top" background="images/right_middle1.gif"><table width="600" border="1" cellpadding="0" cellspacing="0">
<tr>
<td width="141" height="35">贴子主题</td>
<td width="107" height="35">发布人</td>
<td width="141" height="35">发布时间</td>
<td width="92" height="35">是否置顶</td>
<td width="107" height="35">操作</td>
</tr>
<?php
include("conn/conn.php"); //包含conn.php文件
$select=mysql_query("select * from lt_send "); //查询数据
while($row=mysql_fetch_array($select)){ //循环输出查询内容
?>
<tr>
<td height="40"> <span class="STYLE1"><?php echo $row[lt_send_subject];?></span></td>
<td height="40"><span class="STYLE1"><?php echo $row[lt_send_user];?></span></td>
<td height="40"><span class="STYLE1"><?php echo $row[lt_send_date];?></span></td>
<td height="40"><span class="STYLE1"><?php echo $row[lt_send_type];?></span></td>
<td height="40"><span class="STYLE1">
<select name="lt_send_type" id="lt_send_type">
<option value="1">置顶</option>
<option value="0">取消</option>
< lect>
<input type="submit" name="Submit" value="执行" />
</span></td>
</tr>
<?php
} //结束循环
?>
</table>
<p> </p></td>
</tr>
<tr>
<td height="32" background="images/right_bottom.gif"> </td>
</tr>
</table></form>
</body>
bbs_update_tzzd.php
<?php
include("conn/conn.php");
$update_id=$_GET[update_id]; //获取帖子的ID值
//执行帖子置顶或者取消置顶的操作
$query=mysql_query("update lt_send set lt_send_type='$_POST[lt_send_type]' where lt_send_id='$update_id'");
if($query==true){
echo "<script>alert('置顶成功!');history.back();</script>";
}else{
echo "<script>alert('置顶失败!');history.back();</script>";
}
?>
运行结果显示置顶成功,但是lt_send_type字段的值并没有相应的跟着变为1,求高手指点
bbs_tzzd.php
<body>
<form id="form1" name="form1" method="post" action="bbs_update_tzzd.php?update_id=<?php echo $row[lt_send_id];?>">
<table width="700" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td height="32" background="images/right_line.gif"> 您现在的位置:校园馨浪网站后台管理系统</td>
</tr>
<tr>
<td height="32" background="images/right_top.gif"> </td>
</tr>
<tr>
<td height="488" align="center" valign="top" background="images/right_middle1.gif"><table width="600" border="1" cellpadding="0" cellspacing="0">
<tr>
<td width="141" height="35">贴子主题</td>
<td width="107" height="35">发布人</td>
<td width="141" height="35">发布时间</td>
<td width="92" height="35">是否置顶</td>
<td width="107" height="35">操作</td>
</tr>
<?php
include("conn/conn.php"); //包含conn.php文件
$select=mysql_query("select * from lt_send "); //查询数据
while($row=mysql_fetch_array($select)){ //循环输出查询内容
?>
<tr>
<td height="40"> <span class="STYLE1"><?php echo $row[lt_send_subject];?></span></td>
<td height="40"><span class="STYLE1"><?php echo $row[lt_send_user];?></span></td>
<td height="40"><span class="STYLE1"><?php echo $row[lt_send_date];?></span></td>
<td height="40"><span class="STYLE1"><?php echo $row[lt_send_type];?></span></td>
<td height="40"><span class="STYLE1">
<select name="lt_send_type" id="lt_send_type">
<option value="1">置顶</option>
<option value="0">取消</option>
< lect>
<input type="submit" name="Submit" value="执行" />
</span></td>
</tr>
<?php
} //结束循环
?>
</table>
<p> </p></td>
</tr>
<tr>
<td height="32" background="images/right_bottom.gif"> </td>
</tr>
</table></form>
</body>
bbs_update_tzzd.php
<?php
include("conn/conn.php");
$update_id=$_GET[update_id]; //获取帖子的ID值
//执行帖子置顶或者取消置顶的操作
$query=mysql_query("update lt_send set lt_send_type='$_POST[lt_send_type]' where lt_send_id='$update_id'");
if($query==true){
echo "<script>alert('置顶成功!');history.back();</script>";
}else{
echo "<script>alert('置顶失败!');history.back();</script>";
}
?>
运行结果显示置顶成功,但是lt_send_type字段的值并没有相应的跟着变为1,求高手指点
可以把id也用post方式传递(input type='hidden')
是错的,因为你后面用的是。
$update_id=$_GET[update_id];
应该用update_id:name = 'update_id';
换成post:
$update_id = $_POST[update_id];同时把你的sql语句打印出来,看下是否正确
$sql = "update lt_send set lt_send_type='$_POST[lt_send_type]' where lt_send_id='$update_id'";
echo $sql;
<select name="lt_send_type" id="lt_send_type">
<option value="1">置顶</option>
<option value="0">取消</option>
< lect>
先把你的标签完整了。
完整的sql语句打出来是什么?
取值不应该有问题。
$type = $_POST['lt_send_type'];
echo $type;
看取值正常不。