"PHP" database additions and deletions and the interaction between PHP and JavaScript

Source: Internet
Author: User
Tags php database

Using the language to manipulate the database is the most serious, if a language you do not know how to operate the database, then you still do not learn the language.

PHP's approach to manipulating databases is not difficult

The PHP value can also be controlled with JavaScript scripts,

Typically PHP values are passed to JavaScript, and generally do not operate in reverse


I. BASIC OBJECTIVES

First, there is a user information table in MySQL,

The fields are id,username and password, respectively.

To open the Web page dbselect.php, first use PHP to find the entire user table:


You can then insert data into the user table in MySQL by inserting data into a column of data.


In the column that modifies the data, the first drop-down menu is created by JavaScript,

The number of drop-down options given based on how much data is in the table.


The second drop-down menu lets the user select the column to modify

The third input box is for the user to enter a value to modify


As for why the deletion data is not done, it is because the operation to delete data is similar to the modification data, second, because the data is not deleted in the self-increment table, just set the key value so that the data is hidden


Second, the basic idea

The program entrance is dbselect.php, the process of manipulating the database is two new pages, one dbinsert.php, one is dbupdate.php, the two pages operate the database, immediately through JavaScript return.



Third, the production process

(1) dbselect.php

is also the most complex page in the implementation process.

<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
JavaScript control HTML node details, you can refer to my previous "JavaScript" page node additions and deletions of the article (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

It's exactly the same as the dbinsert.php logic, just mysql_query that query, 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 ">

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.