How to modify data in php form

藏色散人
Release: 2023-03-07 17:24:01
Original
1667 people have browsed it

How to modify data in php form: first create the "xiugai.php" page; then execute the statement "select * from info where code='{$code}'"; finally create the "update.php" page and Execute the update command to update the data.

How to modify data in php form

Recommended: "PHP Video Tutorial"

php form modification data

First one Page xiugai.php

    无标题文档 

修改数据

query($sql); $arr = $result->fetch_row(); ?>
姓名:
性别: />男 />女
民族:
生日:
Copy after login

1. The code item is the primary key in the database and cannot be changed, so it must be set to type="hidden". You can also use type="text" style="display:none". The readonly attribute can also be used, but the disable attribute cannot be used. (Disable means to make it unavailable. Although it cannot be modified, it does not pass information to the back.)

2. It is easier to write gender with the ternary operator.

3. Modify the selection of page default value.

4. $db = new MySQLi("localhost","root","root","dbname"); You only need to write it once in this page, and you do not need to write it again in the php code inserted later. .

The second page update.php

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

The above is the detailed content of How to modify data in php form. 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
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!