doucong3048 2017-04-06 08:26
浏览 42

删除按钮不起作用,返回空白页

My delete button is not working.

For a view file it's working - this is my code for view_file.php:

<?php
$sql_id="SELECT * FROM meeting_info where id=".$id ;
`$result2 = $conn->query($sql_id);
if($row2 = $result2->fetch_assoc()) {
$bilno = $row2['bilno'];
}
?>

  <body>
    <div id="body">
      <table align="center" width="90%">
        <tr>
          <th colspan="6">
            <div align="center">
              <h3>Meeting Bil.No
                <?php echo $bilno; ?> </h3>
            </div>
          </th>
        </tr>
        <tr bgcolor="#3366ff">
          <td>Bil. Item</td>
          <td>File Type</td>
          <td>File Size (KB)</td>
          <td>View</td>
          <td>Edit</td>
          <td>Delete</td>
        </tr>
        <?php
$sql="SELECT * FROM meeting_details where id=".$id ." order by item_no asc";
$result = $conn->query($sql);
while($row = $result->fetch_assoc()) 
{
    if($j%2 == 1) {$colortd = "#99ccff";
}
    else    {$colortd = "#f5f5f0";}   
?>
          <tr bgcolor=<?php echo $colortd;?>>
            <td>
              <?php echo $row['item_no'] ?>
            </td>
            <td>
              <?php echo $row['type'] ?>
            </td>
            <td>
              <?php echo $row['size'] ?>
            </td>
            <td>
              <a class="btn btn-view" href="uploads/<?php echo $row['file']; ?>" target="_blank" alt="<?php echo $row['item_no']; ?>" title="click for edit">
                <center><img src="images\iconview.png"></center>
              </a>
            </td>
            <td>
              <a class="btn btn-info" href="edit_file.php?edit=<?php echo $row['id']; ?>" title="click for edit" onclick="return confirm('sure to edit ?')">
                <center><img src="images\iconedit.png"></center>
            </td>
            <td>
              <a class="btn btn-danger" href="delete_file.php?delete=<?php echo $row['id']; ?>" title="click for delete" onclick="return confirm('sure to delete ?')">
                <center><img src="images\icondel.png"></center>
            </td>

          </tr>
          <?php
        $j++;
 }
 //$conn->close();
 ?>
      </table>
    </div>
  </body>

For the delete button, I want to delete all rows on information that I want to delete. But it's not working. When i click the delete button it's just come out the blank page. The data still have in database and website.

This my delete_file.php code:

<?php 
  include("db_conn.php");  
if (isset($_GET['id']) && is_numeric($_GET['id']))
{  
    $id =$_GET['id']; 
    $sql = "DELETE FROM meeting_details WHERE id=".$id; 
    $result = $conn->query($sql);
    
}
$conn->close();
?>

</div>
  • 写回答

1条回答 默认 最新

  • dongqufi82315 2017-04-06 08:31
    关注

    Check this line:

    <a class="btn btn-danger" href="delete_file.php?delete=<?php echo $row['id']; ?>" title="click for delete" onclick="return confirm('sure to delete ?')">
    

    here the delete url is like: delete_file.php?delete=1 and you are fetching the value like:

    $id =$_GET['id'];
    

    So change it to:

    $id =$_GET['delete']; 
    

    and try again.

    Note: Your code is wide open to SQL injection

    评论

报告相同问题?

悬赏问题

  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?
  • ¥15 matlab(相关搜索:紧聚焦)
  • ¥15 基于51单片机的厨房煤气泄露检测报警系统设计
  • ¥15 Arduino无法同时连接多个hx711模块,如何解决?
  • ¥50 需求一个up主付费课程
  • ¥20 模型在y分布之外的数据上预测能力不好如何解决