Mysql查询似乎不起作用

时间:2013-07-25 20:17:03

标签: php mysql

我有一个表单,显示路径存储在mysql中的图像。表单为每个图像都有“隐藏”和“显示”提交按钮。按隐藏按钮应将'status'字段的值设置为2(隐藏)。但它什么也没做,我的查询似乎没有执行。

这是表格

<form  class="removeform"action='headerimageadd.php'  method='post' enctype='multipart/form-data'    
name='image_remove_form' > 
     <?php
     include '../inc/connect.php';
     $q = "SELECT * FROM headerrotatorimage WHERE rotator = 1";
     $result = $link->query($q);
     while($row=mysqli_fetch_array($result)){
        echo "<input type='submit' name='hide[{$row['id']}]' value='Hide'>",
             "<input type='submit' name='show[{$row['id']}]' value='Show'>",
             "<br />",
             "<img src='{$row['filename']}' alt='{$row['name']}' />",
             "<br />";                         
      }
      ?>
      </form>

这是按下隐藏按钮时执行的php

<?php
    include '../inc/connect.php';
    if(isset($_POST['hide'])){
       $chk = (array) $_POST['hide'];
       $p = implode(',',array_keys($chk)); 
       echo $p;
       $t = "SELECT * FROM headerrotatorimage WHERE id IN ($p)";
       echo $t;
       $s = "UPDATE headerrotatorimage SET status = 2 WHERE id IN ($p)";
       echo $s;
    }
    ?>

有人可以帮忙吗? 感谢。

1 个答案:

答案 0 :(得分:0)

您实际上并未在代码中发出查询:

<?php
include '../inc/connect.php';
if(isset($_POST['hide'])){
   $chk = (array) $_POST['hide'];
   $p = implode(',',array_keys($chk)); 
   echo $p;
   $t = "SELECT * FROM headerrotatorimage WHERE id IN ($p)";
   echo $t;

   // Execute query and process result set for $t

   $s = "UPDATE headerrotatorimage SET status = 2 WHERE id IN ($p)";
   echo $s;

   // Execute query and process result set for $s
}
?>