Home > Backend Development > PHP Problem > How to delete a record in php

How to delete a record in php

coldplay.xixi
Release: 2023-03-06 11:54:01
Original
3803 people have browsed it

php method to delete a record: use php mysql to delete the database, the code is [echo '

How to delete a record in php

php method to delete a record:

Deleting a record is Common basic operations between php and database. Below we mainly introduce the method of deleting a record in the database in php mysql. The code is as follows:

echo &#39;<a href="www.phpfensi.com/11.php?id=你要删除记录"onclick="return confirm("是否真的要删除当前记录?")">删除</a>&#39;.
Copy after login

Of course, you can also use the following method to delete it as an example, the code is as follows:

<script language=&#39;javascript&#39;> 
function del(id){ 
    if (false === confirm(&#39;是否真的要删除当前记录?&#39;) )return; 
    location.href = &#39;delete.php?id=&#39; + id; 
} 
</script>
Copy after login

Here you only need to change your database connection username and password, database name and data table name.

<?php 
    $conn = mysql_connect("localhost","root","8588027"); 
    mysql_select_db("test"); 
    $exec="delete from content where id=&#39;{$_get[&#39;id&#39;]}&#39;"; 
    mysql_query($exec); 
    mysql_close(); 
    echo "<script language=&#39;javascript&#39;>location.href=&#39;code.php&#39;;</script>"; 
?>
Copy after login

If you want to learn more about programming, please pay attention tophp training Column!

The above is the detailed content of How to delete a record in php. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
php
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template