这是我帖子置顶的代码
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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;您现在的位置:校园馨浪网站后台管理系统</td>
  </tr>
  <tr>
    <td height="32" background="images/right_top.gif">&nbsp;</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">&nbsp;<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>&nbsp;</p></td>
  </tr>
  <tr>
    <td height="32" background="images/right_bottom.gif">&nbsp;</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,求高手指点

解决方案 »

  1.   

    看看数据库里信息变了没。尽量少用history.back()。它只是返回,信息刷新后才会显示更新
      

  2.   

    这种问题 先把sql打印出来放到数据库执行 然后再找原因
      

  3.   

    <form id="form1" name="form1" method="post" action="bbs_update_tzzd.php?update_id=<?php echo $row[lt_send_id];?>">你这种id放到action里边,在数据库查出数据之前,id值是无法取到的,所以没有传递过去。
    可以把id也用post方式传递(input type='hidden')
      

  4.   

    具体怎么写哦,我写了<input type="hidden" name="id" value="<?php echo $row['lt_send_id'];?>"/>也不对
      

  5.   

    name="id"
    是错的,因为你后面用的是。
    $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;
      

  6.   

    后面有输出1,但是前面lt_send_type的值没有变,还是0,这是怎么回事啊
      

  7.   


      <select name="lt_send_type" id="lt_send_type">
      <option value="1">置顶</option>
      <option value="0">取消</option>
      < lect>
    先把你的标签完整了。
      

  8.   


    完整的sql语句打出来是什么?
    取值不应该有问题。
    $type = $_POST['lt_send_type'];
    echo $type;
    看取值正常不。