Php database addition, deletion, modification, query, interaction between php and javascript, phpjavascript

Source: Internet
Author: User
Tags php database

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.