require_once('../connect.php'); //Read old information $id = $_GET['id']; $query = mysqli_query($con,"select * from article where id=$id"); $data = mysqli_fetch_assoc($query); ?>
//Write sql modification statement and do Determine whether it is successful or not, and jump back to the modification interface $updatesql = "update article set title='$title',author='$author',description='$description',content='$content',dateline =$dateline where id=$id"; if(mysqli_query($con,$updatesql)){ echo "<script>alert('Article modified successfully');window.location.href=' article.manage.php';</script>"; }else{ echo "<script>alert('Failed to modify article');window.location.href='article.manage.php ';</script>"; } ?>
5.5 Article Deletion
First do a demand analysis: It is slightly different from the above. Deleting an article does not require an interface, just a delete button to delete it . So there is only one file. The key sql statement is only one sentence
$delsql="delete from article where id=$id";
aritcle.del.handle.php
require_once('../connect.php');
//Read the id number. Unlike others that pass values $id = $_GET['id']; $deletesql = "delete from article where id=$id"; if(mysql_query($deletesql) ){ echo "<script>alert('Article deleted successfully');window.location.href='article.manage.php';</script>"; }else{ echo "<script>alert('Failed to delete article');window.location.href='article.manage.php';</script>"; } ?>
5.6 Article Management List
Requirements analysis: A list displays all articles, followed by two buttons, Delete (link to the deleted module in the previous section) and Modify (link to the previous module)
So, you only need one file, just display the module
article.manage.php
require_once('../connect.php'); $sql = "select * from article order by dateline desc"; $query = mysqli_query($con, $sql); if($query&&mysqli_num_rows($query)){ while($row =mysqli_fetch_assoc($query)){ $data[] = $row; } }else{ $data = array(); }
http://www.bkjia.com/PHPjc/1077541.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/1077541.htmlTechArticle Knock on -PHP and MySQL, JSON, -phpmysqljson hi Knock on the code~ 1. The modification interface of php and mysql 5.4 is the same Interface and program. Interface article.modify.php ?php require_once('../connect.php'); //Read...
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn