Php database addition, deletion, modification, query, interaction between php and javascript, phpjavascript
Using languages to operate databases is a top priority. If you do not know how to operate databases in a language, you still have not learned this language.
PHP database operations are not difficult
At the same time, php values can be controlled with JavaScript scripts.
Generally, the php value is passed to javascript and will not be reversed.
I. Basic Objectives
First, there is a user information table in mysql, where the fields are id, username and password. Open the web page dbselect. php. First, use php to find the entire user table:
Then, insert a column of data and input data to insert the data to the user table in mysql.
In the "modify data" column, the first drop-down menu is created by using javascript. The drop-down menu is based on the amount of data in the table.
The second drop-down menu allows you to select the columns to be modified
The third input box is to ask the user to enter the value to be modified.
The reason why data is not deleted is that the operation to delete data is similar to modifying data. The second reason is that data is not deleted in the auto-increment table, and only the key value is set to hide the data.
Ii. Basic Ideas
The program entry is dbselect. php. The database operation process is two new pages, one is dbinsert. php and the other is dbupdate. php. After these two pages operate on the database, they are immediately returned through javascript.
Iii. Production Process
(1) dbselect. php
It is also the most complex page in this implementation process.
<! DOCTYPE html PUBLIC "-// W3C // dtd xhtml 1.0 Transitional // EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
For details about how javascript controls html nodes, refer to my previous article "add, delete, modify, and query of [JavaScript] webpage nodes" (click to open the link)
(2) dbinsert. php
<! DOCTYPE html PUBLIC "-// W3C // dtd xhtml 1.0 Transitional // EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
(3) dbupdate. php
The logic is exactly the same as that of dbinsert. php, but the query statement of mysql_query has changed from the insert into statement to the update statement.
<! DOCTYPE html PUBLIC "-// W3C // dtd xhtml 1.0 Transitional // EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
The above is the entire production process.
The above is all the content of this article. I hope it will be helpful for your learning and support for helping customers.