【问题标题】:Code for a checkbox that will enable me to choose which to delete in php一个复选框的代码,使我能够选择在 php 中删除哪个
【发布时间】:2013-01-13 03:53:08
【问题描述】:

我有这段代码可以显示我的数据库中的条目。

<html>
<head>
<center>

<form action="delete.php">

<a href='display.php'><input type='submit' value='Delete Records'></a></th></tr><br><br><br></form>

<?php

mysql_connect("localhost","root","");

mysql_select_db("bfp6");

$result=mysql_query("Select*From station");

$display="<table border=\"1\"><tr>

<th><font color='yellow'>ID&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</th>

<th><font color='yellow'>Station&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</th>

<th><font color='yellow'>Email&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</th>

<th><font color='yellow'>Password&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</th><td></tr>";

while($row=mysql_fetch_array($result)){

$id=$row['id'];

$stations=$row['stations'];

$email=$row['email'];

$password=$row['password'];

$z="<tr><td>".$id."</td><td>".$stations."</td><td>".$email."</td><td>".$password."</td><tr>";

$display=$display.$z;}

$display=$display."</table>";

echo $display;

?><html><body bgcolor="eb3a3a"></body></html>

这是我删除记录的代码(单击即可删除所有记录,除了 id = 234 的记录)

<?php

error_reporting(0);

header("location:display.php");

$con=mysql_connect("localhost","root","");

mysql_select_db("bfp6",$con);

$result=mysql_query("DELETE FROM station WHERE id<>234");

$row=mysql_fetch_array($result);

mysql_close($con);

?>

伙计们,我将如何为复选框添加代码,每当我单击时,比如说一个名为“标记要删除的项目”的按钮,它就会出现,当我选中这些并单击删除按钮时,只有选中的才会出现被删除..请大家帮忙。我不太擅长这个:(

【问题讨论】:

标签: php mysql database wamp web-development-server


【解决方案1】:

看起来您的标头在数据库可以连接之前重定向...

【讨论】:

    猜你喜欢
    • 2018-12-11
    • 2012-01-21
    • 2013-10-21
    • 1970-01-01
    • 1970-01-01
    • 2020-11-02
    • 2021-07-11
    • 1970-01-01
    • 2012-11-22
    相关资源
    最近更新 更多