Copy Code code as follows:
<?php
@mysql_connect ("localhost", "root", "1981427")//Select database before you need to connect to the database server
Or Die ("Database server Connection Failed");
@mysql_select_db ("test")//Select Database MyDB
Or Die ("database does not exist or not available");
$query = @mysql_query ("SELECT * from TableName1")//Execute SQL statement
Or Die ("SQL statement execution failed");
echo "<form method= ' post ' name= ' Form1 ' action= ' delete_do.php ' >";
echo "<table border=1>";
Output all records from line No. 0 to largest row in a circular fashion
for ($i =0; $i <mysql_numrows ($query); $i + +)
{
$id = mysql_result ($query, $i, ' id '); Output the Serial_no column of line $i
$username = mysql_result ($query, $i, ' username '); Output the Name column of the $i row
$password = mysql_result ($query, $i, ' password '); Output the salary column of line $i
echo "<tr>";
echo "<td><input type= ' checkbox ' name= ' chk[] ' value= ' $id ' ></td> ';
echo "<td> $id </td>";
echo "<td> $username </td>";
echo "<td> $password </td>";
echo "</tr>";
}
echo "<tr>";
echo "<td colspan=4 nowrap><input name= ' submission ' type= ' submit ' value= ' submitted ' > ';
echo "<input type= ' reset ' name= ' reset ' value= ' reset ' ></td>";
echo "</tr></table></form>";
?>
Copy Code code as follows:
<?php
@mysql_connect ("localhost", "root", "1981427")//Select database before you need to connect to the database server
Or Die ("Database server Connection Failed");
@mysql_select_db ("test")//Select Database MyDB
Or Die ("database does not exist or not available");
foreach ($_post[' chk '] as $check)
{
$query = mysql_query ("Delete from tablename1 where id = $check");
if ($query)
echo "Delete Success";
Else
echo "Delete Failed";
}
Mysql_close ();
?>