Home >Backend Development >PHP Tutorial >PHP delete record implementation code

PHP delete record implementation code

WBOY
WBOYOriginal
2016-07-29 08:39:35999browse

Copy the code The code is as follows:


@mysql_connect("localhost", "root","1981427") //You need to connect to the database server before selecting the database
or die("Database server Connection failed");
@mysql_select_db("test") //Select database mydb
or die("Database does not exist or is unavailable");
$query = @mysql_query("select * from tablename1") //Execute SQL Statement
or die("SQL statement execution failed");
echo "

";
echo " ";
//Output all records from row 0 to the largest row in a loop
for($i=0; $i{
$id = mysql_result($ query, $i, 'id'); //Output the serial_no column of row $i
$username = mysql_result($query, $i, 'username'); //Output the name column of row $i
$password = mysql_result($query, $i, 'password'); //Output the salary column of row $i
echo "
";
echo "";
echo "";
echo "";
echo "";
echo "";
}
echo "";
echo "";
echo "
$id$username$password
";
echo "
";
?>


Copy code The code is as follows:


@mysql_connect("localhost ", "root","1981427") //You need to connect to the database server before selecting the database
or die("Database server connection failed");
@mysql_select_db("test") //Select the database mydb
or die(" The database does not exist or is unavailable");
foreach($_POST['chk'] AS $check)
{
$query = mysql_query("delete from tablename1 where id = $check");
if($query)
echo "Deletion successful";
else
echo "Deletion failed";
}
mysql_close();
?>

The above introduces the PHP deletion record implementation code, including the relevant content. I hope it will be helpful to friends who are interested in PHP tutorials.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn