复选框的代码,使我能够选择在php中删除哪个

时间:2013-01-29 14:30:05

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

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

<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);

?>

那么伙计们,我怎么会为一个复选框添加一个代码,每当我点击时,让我们说一个名为“标记要删除的项目”的按钮,它会出现,当我检查那些并单击删除按钮时,只有那些被检查的将被删除..请在这里帮助一下。我不是很擅长这个:(

1 个答案:

答案 0 :(得分:0)

在数据库可以连接之前看起来你的标题是重定向的......