想要实现屏蔽回帖,代码如下,好像值没有传递过去,点击屏蔽和取消都只显示一空白页,while语句读不懂(红色部分),不知道怎样修改,求帮忙。<body>
<form id="form1" name="form1" method="post" action="bbs_htgl_ok.php">
<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_middle.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="130" height="35">回复内容</td>
        <td width="105" height="35">原帖</td>
        <td width="105" height="35">标记</td>
      </tr>
<?php
    include("conn/conn.php"); //包含conn.php文件
$select=mysql_query("select * from lt_reply " ); //查询数据
while($row=mysql_fetch_array($select)){ //循环输出查询内容
?>
      <tr>
        <td height="41">
          <input name="<?php echo $row[lt_reply_id];?>" type="checkbox" value="<?php echo $row[lt_reply_id];?>" />        </td>
        <td height="41"><?php echo $row[lt_reply_subject];?></td>
        <td height="41"><?php echo $row[lt_reply_content];?></td>
        <td height="41">
<?php 
$sql=mysql_query("select * from lt_send where lt_send_id='".$row[lt_send_id]."'");
$myrows=mysql_fetch_array($sql);
echo $myrows[lt_send_subject];
?>        </td>
        <td height="40">
          <?php if($row[lt_reply_tag]==1){echo "已屏蔽";}else{echo "未屏蔽";}?>        </td>
      </tr>
  <?php
      }
      ?>
      <tr>
        <td height="40">
<input name="button" type="button" class="buttoncss" onclick="checkAll(form1,status)" value="全选" />
<input name="button2" type="button" class="buttoncss" onclick="uncheckAll(form1,status)" value="不选" />
          <input name="button" type="button" class="buttoncss" onclick="switchAll(form1,status)" value="反选" /></td>
        <td height="40">&nbsp;</td>
        <td height="40">&nbsp;</td>
        <td height="40">&nbsp;</td>
        <td height="40"><span class="STYLE1">
          <input type="submit" name="Submit" value="屏蔽" /><input type="submit" name="Submit2" value="取消" />
        </span></td>
      </tr>
    </table>
      </td>
  </tr>
  <tr>
    <td height="32" background="images/right_bottom.gif">&nbsp;</td>
  </tr>
</table></form>
</body>这是bbs_htgl_ok.php
<?php 
session_start(); 
include("conn/conn.php");
if($Submit=="屏蔽"){
    while(list($name,$value)=each($_POST)){    
         $result=mysql_query("update lt_reply set lt_reply_tag='1' where lt_reply_id='".$name."'");          
    if($result==true){
    echo "<script>alert('屏蔽成功!'); window.location.href='index.php?title=回帖管理';</script>";}}
}

if($Submit2=="取消"){
    while(list($name,$value)=each($_POST)){    
         $result=mysql_query("update lt_reply set tb_restore_tag='0' where lt_reply_id='".$name."'");          
    if($result==true){
    echo "<script>alert('取消屏蔽!'); window.location.href='index.php?title=回帖管理';</script>";}}
}
?>

解决方案 »

  1.   

    仍旧是表单处理方式的问题
      <input type="submit" name="Submit" value="屏蔽" />
      <input type="submit" name="Submit2" value="取消" />
    if($Submit=="屏蔽")
    if($Submit2=="取消")
    如下问题
     $Submit未定义, 外部数据请用 $_POST['Submit'], 改为 if($_POST['Submit']=="屏蔽")
     请最好不要用 =="屏蔽" 作为判断是否提交,比较汉字很容易因为乱码出问题 改为 if( isset( $_POST['Submit'])) while(list($name,$value)=each($_POST)) 不带这么写的     foreach( $_POST as $name=>$value ) // $name === $value
          {
              $result = mysql_query("update lt_reply set tb_restore_tag='0' where lt_reply_id='".$name."'");
              if( mysql_affected_rows() >= 0 )
                 echo "<script>alert('屏蔽成功!'); window.location.href='index.php?title=回帖管理';</script>";
              else
                  echo "出错了:".mysql_error();
          } 建议你把php的错误级别开到最低,这样也就不用劳神费心跑到这儿找答案了。