前言:在开发一套信息管理系统时,离不开的是对数据库的"增删改查"。其中的修改数据库中的信息无疑是比较难的一项。首先需要对信息进行查询,展现给客户,客户查看信息后,对某个字段进行修改。最后更新数据库。
My Difficulty:
1、option标签根据数据库中信息动态显示选项
2、用户提交修改信息时,将该条数据的id传递到服务端进行更新数据表(数据id悄悄传递,不能被用户看到)。
part one:将要修改的某条数据传递给修改页面。
1、确定选用的数据表,查询条件。
<?php
require_once '../functions/mysql.func.php';
require_once '../config/config.php';
header("content-type:text/html;charset=utf-8");
$link = connect3();
//定义page=1页面
$page = $_GET['page']?$_GET['page']:1;
$pageSize = 25;
$offSet = ($page-1)*25;
$table = "siteinfo";
$totalRows = getTotalRows($link, $table);
$sumPage = ceil($totalRows/$pageSize);
$query = "select * from siteinfo limit {
$offSet},{
$pageSize}";
$rows = fetchAll($link, $query);
$num=1;
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1">
<title>网站列表</title>
<link rel="stylesheet" href="static/css/bootstrap.min.css">
<script src="static/js/jquery-3.1.0.min.js"></script>
<script src="static/js/bootstrap.min.js"></script>
<style type="text/css">
body{
font-family: 'Microsoft YaHei';}
/*.panel-body{ padding: 0; }*/
span{
color: blue;
}
</style>
<!-- js弹出对话框 -->
<script>
$(function(){
$(".delect").click(function(){
if(confirm("确定删除该网站信息?")){
//点击确定后操作
var id = $(this).attr("data_id");
var url = "server/siteInfo_doAction.php?id="+id;
$.get(url);
$(this).parent().parent().empty();
}
});
});
</script>
</head>
<body>
<div class="jumbotron">
<div class="container">
<h1>评论语料管理系统</h1>
</div>
</div>
<div class="container">
<div class="main">
<div class="row">
<!-- 左侧内容 -->
<div class="col-md-3">
<div class="list-group">
<a href="layout-index.php?page=1" class="list-group-item text-center ">评论列表</a>
<a href="layout-form.html" class="list-group-item text-center">新增语料</a>
<a href="website_info.php?page=1" class="list-group-item text-center active">网站信息</a>
<a href="user_info.php?page=1" class="list-group-item text-center ">评论用户</a>
</div>
</div>
<!-- 右侧内容 -->
<div class="col-md-9">
<!-- 成功提示框 -->
<div class="alert alert-success alert-dismissible" style="display: none" role="alert">
<button type="button" class="close" data-dismiss="alert"><span aria-hidden="true">×</span><span class="sr-only">Close</span></button>
<strong>成功!</strong> 操作成功提示
</div>
<!-- 失败提示框 -->
<div class="alert alert-danger alert-dismissible" style="display: none" role="alert">
<button type="button" class="close" data-dismiss="alert"><span aria-hidden="true">×</span><span class="sr-only">Close</span></button>
<strong>失败!</strong> 操作失败提示
</div>
<!-- 自定义内容 -->
<div class="panel panel-default">
<div class="panel-heading"><strong style=" font-size: 16px">当前位置:</strong>网站列表 <a href="addWebsite.html" style="margin-left: 570px;font-size:15px;color:red" ><b>添加网站信息</b></a>
</div>
<div class="panel-body">
<table class="table table-striped table-responsive table-hover">
<thead>
<tr>
<th width="50">编号</th>
<th>媒体名称</th>
<th>评论事件</th>
<th>评论时间</th>
<th width="120">操作</th>
</tr>
</thead>
<tbody>
<?php