我的删除页面尚未删除但显示成功消息。但它也会显示如下ID错误:
注意:未定义的索引:第3行的C:\ wamp \ www \ Potifolio \ delete.php中的player_id
成功删除记录:
<?php
#connect to the database
include_once('connect.php');
$strSQL = "SELECT * FROM players";
// Execute the query (the recordset $rs contains the result)
$rs = mysql_query($strSQL);
// Loop the recordset $rs
// Each row will be made into an array ($row) using mysql_fetch_array
echo "
<table border='1' >
<tr bgcolor='#cccccc'>
<td>Name</td>
<td>Surname</td>
<td>Contact Number</td>
<td>Email</td>
<td>Position</td>
<td>User Nmae</td>
<td>Password</td>
<td colspan='2'>Action</td>
</tr>
";
while($row = mysql_fetch_array($rs)) {
$player_id = $row['player_id'];
$name = $row['name'];
$surname = $row['surname'];
$contact_number = $row['contact_number'];
$email = $row['email'];
$position = $row['position'];
$username = $row['username'];
$password = $row['password'];
$surname = mysql_real_escape_string($surname);
$name = mysql_real_escape_string($name);
$email = mysql_real_escape_string($email);
$position = mysql_real_escape_string($position);
$username = mysql_real_escape_string($username);
$password = mysql_real_escape_string($password);
echo "
<tr bgcolor='#cccccc'>
<td>$name</td>
<td>$surname</td>
<td>$contact_number</td>
<td>$email</td>
<td>$position</td>
<td>$username</td>
<td>$password</td>
<td><a href='edit.php?player_id=$player_id'>Edit</a></td>
<td><a href='delete.php?player_id=$player_id'>Delete</a></td>
</tr>
";
}
echo'</table>';
?>
<?php
include_once("connect.php");
$player_id = $_POST['player_id'];
$delete= "DELETE FROM players WHERE player_id = '$player_id'";
$result = mysql_query($delete);
if($result){
echo "Record deleted successfuly ";
}else{
echo "No data deleted";
}
?>