In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly introduces how to use PHP+Mysql to achieve addition, deletion, modification and search, which has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, let the editor take you to understand it.
PHP+Mysql to add, delete, modify and check
PHP is a powerful server-side scripting language for creating dynamic interactive sites.
Database (Database) is a warehouse that organizes, stores and manages data according to the data structure. Each database has one or more different API for creating, accessing, managing, searching, and replicating saved data.
MySQL is a database system that is used on Web and runs on the server; MySQL is very fast, reliable, and easy to use, supporting standard SQL.
Mysql statement
Open our wampserver server + Mysql visualization tool (I use Navicat here), or other integration tools (Apache+PHP+Mysql) will do. Link to our server
Let's create a new query to operate the database and configure the basic files first.
Insert a message
INSERT INTO syntax
You need to specify the name of the column in which you want to insert the data, simply provide the value to be inserted
INSERT INTO table_name VALUES (value1,value2,value3,...)
You need to specify the column name and the value to be inserted
INSERT INTO table_name (column1,column2,column3,...) VALUES (value1,value2,value3,...)
Insert a piece of data into the table without specifying the column name
INSERT INTO stu VALUES (null,' Timo', 1Time30)
We insert a piece of data into the table with the second syntax.
INSERT INTO stu (name, gender, age) VALUES ('Faker', 0Jet 24)
Query statement
SQL SELECT statement
SELECT column_name,column_name FROM table_name;SELECT * FROM table_name
Query the id column
Select id from stu
Query the statement when id is 1
Select * from stu where id = 1
Because id is unique, you don't have to continue when you find this piece of data
Select * from stu where id = 1 limit 1; modify statement
SQL UPDATE statement needs to be added with where statement, otherwise the whole table will be updated
UPDATE table_name SET column1=value1,column2=value2,... WHERE some_column=some_value
Change the name when id is 1
Update stu set name='the shy' where id=1; delete statement
The SQL DELETE syntax WHERE clause specifies which records or records need to be deleted. If you omit the WHERE clause, all records will be deleted!
DELETE FROM table_name WHERE some_column=some_value
Delete the student information with id 2
Delete from stu where id = 2; use PHP to manipulate how Mysql links database header ("Content-Type:text/html;charset=utf-8"); / / 1. Use mysqli to link to the database (wampserver default is used here) $connection = mysqli_connect ('127.0.0.1,' root',', 'students'); / / 2. Resolve Chinese mysqli_query ($connection, "set names' utf8';") that cannot recognize database files; if (! $connection) {/ / failed to connect to database exit ('failed to connect to database');} / / query only one piece of data at a time $query = mysqli_query ($connection, 'select * from stu;'); / / query all data while ($row = mysqli_fetch_assoc ($query)) {var_dump ($row) } query database rendering main page (index.php)
The method of mixed compilation is adopted to link the database in the head.
Introduce bootstrap@4 (download from bootstrap official website and introduce bootstrap.css)
Use mysqli_fetch_assoc ($query) to render data, because you need to add (add.php), delete (del.php), and modify (edit) later, so add it here first.
Home page student number name, gender and age operation
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.