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.
Recommended: "PHP Video Tutorial"
php form modification data
First one Page xiugai.php
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 "修改失败!"; }
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!