Implementation of modification function of news management system developed with PHP (Part 1)

As mentioned in the previous section, the information of our database has been displayed. Have you noticed that the two connections are modified and deleted? I wrote a statement to output the id

Modify

Delete

Modify, we must get the id, query from the data based on the id, and then modify other fields of the id Content, let’s look at the following modification flow chart

md.png

Click to modify, and an id will be passed to the file modifynew.php,

this page It is a modified page, the effect is as follows:

104.png

In this page, we need to query the database based on the id just passed, and then display the title content

First connect to the database:

header("Content-type: text/html; charset=utf-8");//Set encoding
$con =@mysql_connect("localhost", "root","root") or die("Database connection failed");
mysql_select_db('news') or die("The specified database cannot be opened");
mysql_query("set names utf8") ;//Set the character set of the database

and then get the id

The id on the form We use the get method to obtain

$id=$_GET['id '];

We query in the database based on id

$sql="select * from new where id=$id";
$res = mysql_query($sql);
$row = mysql_fetch_array($res);

After querying the information, we need to display the information on the page

The code of the html page is as follows:

      
标题:

内容:

In this way, the information we query from the database is displayed


The complete source code is as follows:

       
标题:

内容:


Continuing Learning
||
标题:

内容:

submit Reset Code
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!