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

Source: Internet
Author: User

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

    1. 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

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.