Example of adding, deleting, modifying and checking user data by connecting to the database in PHP

黄舟
Release: 2023-03-15 17:54:01
Original
3827 people have browsed it

The following editor will bring you an overall operation example of using PHP to connect to the database to implement addition, deletion, modification and query of user data. The editor thinks it’s pretty good, so I’ll share it with you now and give it as a reference. Let’s follow the editor and take a look.

main page(main page)


query($sql); $attr = $result->fetch_all(); foreach($attr as $v) { $sex = $v[2]? '男':'女';  //三元运算符判断性别 $sql = "select Name from Nation where Code ='$v[3]'"; $result = $db ->query($sql); $attr = $result->fetch_assoc(); echo ""; } ?> 
代号 姓名 性别 民族 生日 操作
{$v[0]} {$v[1]} {$sex} {$attr['Name']} {$v[4]} 删除 修改

添加数据

Copy after login

Add(Add data page)


##

添加数据

代号:

姓名:

性别:

民族:

生日:

Copy after login

AddChuLi page(Add data processing page)


query($sql); if($result) { header("location:main.php");  //php跳转页面方式 } else { echo "添加失败!"; }
Copy after login

DeleteChuLi page (Delete data processing page)


query($sql); if($r) { header("location:main.php"); } else { echo "删除失败!"; }
Copy after login

Update page (modify data page)


修改数据

query($sql1); $att1 = $r1->fetch_row(); ?>

代号:

姓名:

性别: />男 />女

民族:

生日:

Copy after login

ateChuLi page (modify data Processing page)


query($sql); if($r) { header("location:main.php"); } else { echo "修改失败!"; }
Copy after login

The above is the detailed content of Example of adding, deleting, modifying and checking user data by connecting to the database in PHP. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
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
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!