PHP
Practical Foundation--with a news
CMS
A case study of adding and deleting
First, Environment Configuration
Second, Database Creation
Third, Change and delete Demo
- Connecting to a database
<?php
$link =mysql_connect ("localhost", "root", "root");
mysql_select_db ("demo", $link);
mysql_query ("Set names UTF8");
?>
2. Check--News list index.php
(1) Check only one article
(2) While loop check multiple strips
(3) Two usages of the mysql_query () function: A. Set character encoding B. Execute SQL statement
(4) connection string in PHP: Connect using the. Number (which is connected by the + sign in the Java Web)
(5) SQL statement: SELECT * from table1 where range;
3. Increase--Add news add.php adddo.php
(1) Form form via submit value, using POST method to receive:
Example: $title =$_post["title"];
(2) SQL statement: INSERT INTO table1 (field1,field2) values (value1,value2);
4. Delete--Remove news deletedo.php
(1) The <a> tag is passed through a URL and received using the Get method:
Cases:
<a href=deletedo.php?id=<?php echo $info [' demo_test_id ']?>> delete </a>
Example: $id =$_get["id"];
(2) SQL statement: Delete from table1 where range;
5. Change--Change the news update.php updatedo.php
(1) difference from adding news: A. To change the first B. To specify the ID of the news
(2) pass an ID with a hidden input
Example: <input name="id" type="hidden" value= "<?php echo $id;? > "/>
(3) SQL statement: Update table1 set field1=value1 where scope;
By the teacher invited to the academy to create a team to train PHP, to a real news cms additions and deletions to check the demo as an example, the documentation handout for everyone to reference