edit.php
<?php
/**
* Created by PhpStorm.
* User: Administrator
* Date: 2019/7/8
* Time: 16:07
*/
?>
<html>
<head>
<title>新闻管理系统</title>
</head>
<body>
<center><?php
include ("menu.php");
require ("dbconfig.php"); //导入配置文件
header("Content-Type:text/html;charset=utf-8");
$link = mysqli_connect(HOST,USER,PASS) or die("数据库连接失败!");
mysqli_select_db($link,DB_NAME);
//mysqli_set_charset($link,"names utf8");
$sql = "select * from news where id={$_GET["id"]}";
$result = mysqli_query($link,$sql); //获得结果集
if($result && mysqli_num_rows($result)>0){ //判断是否获得数据
$news = mysqli_fetch_assoc($result);
}else{
echo "没有找到要修改的信息!";
}
// print_r($news); //数组打印
?>
<h3>编辑新闻</h3>
<form action="action.php?action=update" method="post">
<input type="hidden" name="id" value="<?php echo "{$news['id']}"?>"/>
<table width="320" border="0">
<tr>
<td align="right">标题:</td>
<td><input type="text" name="title" value="<?php echo "{$news['title']}"?>"/></td>
</tr>
<tr>
<td align="right">关键字:</td>
<td><input type="text" name="keywords" value="<?php echo "{$news['keywords']}"?>"></td>
</tr>
<tr>
<td align="right">作者:</td>
<td><input type="text" name="author" value="<?php echo "{$news['author']}"?>"></td>
</tr>
<tr>
<td align="right">内容:</td>
<td><textarea cols="25" rows="5" name="content"><?php echo "{$news['content']}"?></textarea></td>
</tr>
<tr>
<td colspan="2" align="right">
<input type="submit" value="确定">
<input type="reset" value="重置">
</td>
</tr>
</table>
</form>
</center>
</body>
</html>
作者纯属小白,各位大佬有问题可以找我,大家一起探讨哦,附加联系方式
Q Q:1799158338
微信:15903486297