好吧,这是我的错误,数据成功删除,但错误出来了..这是我的search.php编码。第 30 行的错误
<?
mysql_connect("localhost","root","");
mysql_select_db("kuih2") or die("database could not connect ");
?>
search.php 的 html 代码
<html>
<head>
<meta name="description" content="Php Code for View, Search, Edit and Delete
Record" />
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Search Student Record</title>
</head>
<body>
<center><h1><u>Student Database</u></h1></center>
<form name="search" method="post" action="search.php">
<table style=" border:1px solid silver" cellpadding="5px" cellspacing="0px"
align="center" border="0">
<tr>
<td colspan="3" style="background:#0066FF; color:#FFFFFF; fontsize:
20px">Search</td></tr>
<tr>
<td>Enter Search Keyword</td>
<td><input type="text" name="search" size="40" /></td>
<td><input type="submit" value="Search" /></td>
</tr>
<tr bgcolor="#666666" style="color:#FFFFFF">
<td>Roll & class</td>
<td>Name & Father's Name</td>
<td> </td>
search.php 编码
<?
$search=$_POST["search"];//the error is here
$flag=0;
$query="select * from itemorder where id like '%$search%' ";
$result=mysql_query($query);
while ($row = mysql_fetch_array($result)) {
$flag=1;
echo "<tr ><td>",$row[0],", ",$row[1],"</td><td><a
href='view.php?id=",$row[0],"'>",$row[2],", ",$row[3],"</a></td><td><a
href='edit.php?id=",$row[0],"'>Edit</a> | <a
href='del.php?id=",$row[0],"'>Delete</a></td></tr>";
}
if($flag==0)
echo "<tr><td colspan='3' align='center' style='color:red'>Record not
found</td></tr>";
?>
<tr>
<td colspan="3"> </td></tr>
<tr bgcolor="#CCCCCC">
<th colspan="3" align="right"></th>
</tr>
</table>
</form>
</body>
</html>
然后这是我的 del.php 编码...
<?
mysql_connect("localhost","root","");
mysql_select_db("kuih2") or die("database could not connect ");
?>
<html>
<head>
<meta name="description" content="Php Code for View, Search, Edit and Delete
Record" />
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Add Student Record</title>
</head>
<body>
<?
$id=$_GET["id"];
$query="delete from itemorder where id=$id";
mysql_query($query);
echo "<center>Successfully Deleted</center>";
include("search.php");
?>