优化 数据库连接
This commit is contained in:
parent
b869f1b140
commit
a3046f3b6b
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
$title='搜索引擎设置';
|
||||
include './head.php';
|
||||
$sousrows=mysqli_num_rows(mysqli_query($con, "SELECT * FROM `lylme_sou`"));
|
||||
$sousrows=$DB->num_rows($DB->query("SELECT * FROM `lylme_sou`"));
|
||||
?>
|
||||
<main class="lyear-layout-content">
|
||||
|
||||
|
@ -72,8 +72,9 @@ echo '<h4>新增搜索接</h4>
|
|||
elseif($set=='edit')
|
||||
{
|
||||
$id=$_GET['id'];
|
||||
$row2 = mysqli_query($con,"select * from lylme_sou where sou_id='$id' limit 1");
|
||||
$row=mysqli_fetch_assoc($row2);
|
||||
|
||||
$row2 = $DB->query("select * from lylme_sou where sou_id='$id' limit 1");
|
||||
$row= $DB->fetch($row2);
|
||||
echo '<h4>修改搜索引擎</h4>
|
||||
<div class="panel-body">
|
||||
<form action="./sou.php?set=edit_submit&id='.$id.'" method="POST">
|
||||
|
@ -153,8 +154,7 @@ $sql="INSERT INTO `lylme_sou` (`sou_id`, `sou_alias`, `sou_name`, `sou_hint`, `s
|
|||
(NULL, '".$alias."', '".$name."', '".$hint."', '".$color."', '".$link."', '".$waplink."', '".$icon."', '".$st."', '".$sou_order."');
|
||||
";
|
||||
|
||||
|
||||
if(mysqli_query($con,$sql)){
|
||||
if($DB->query($sql)){
|
||||
echo '<script>alert("添加搜索引擎 '.$name.' 成功!");window.location.href="/admin/sou.php";</script>';
|
||||
}else
|
||||
echo '<script>alert("添加搜索引擎失败!");history.go(-1);</script>';
|
||||
|
@ -163,8 +163,8 @@ if(mysqli_query($con,$sql)){
|
|||
elseif($set=='edit_submit')
|
||||
{
|
||||
$id=$_GET['id'];
|
||||
$rows2 = mysqli_query($con,"select * from lylme_sou where sou_id='$id' limit 1");
|
||||
$rows=mysqli_fetch_assoc($rows2);
|
||||
$rows2 = $DB->query("select * from lylme_sou where sou_id='$id' limit 1");
|
||||
$rows=$DB->fetch($rows2);
|
||||
if(!$rows)
|
||||
echo '<script>alert("当前记录不存在!");history.go(-1);</script>';
|
||||
$name=$_POST['name'];
|
||||
|
@ -183,7 +183,8 @@ if (empty($name) && empty($alias)&& empty($hint) && empty($link) && empty($color
|
|||
|
||||
$sql="UPDATE `lylme_sou` SET `sou_alias` = '".$alias."', `sou_name` = '".$name."', `sou_hint` = '".$hint."', `sou_color` = '".$color."', `sou_link` = '".$link."', `sou_waplink` = '".$waplink."', `sou_icon` = '".$icon."', `sou_st` = '".$st."', `sou_order` = '".$order."' WHERE `lylme_sou`.`sou_id` = ".$id.";";
|
||||
|
||||
if(mysqli_query($con,$sql))
|
||||
|
||||
if($DB->query($sql))
|
||||
echo '<script>alert("修改搜索引擎 '.$name.' 成功!");window.location.href="/admin/sou.php";</script>';
|
||||
else
|
||||
echo '<script>alert("修改失败!");history.go(-1);</script>';
|
||||
|
@ -193,7 +194,7 @@ elseif($set=='delete')
|
|||
{
|
||||
$id=$_GET['id'];
|
||||
$sql="DELETE FROM lylme_sou WHERE sou_id='$id'";
|
||||
if(mysqli_query($con,$sql))
|
||||
if($DB->query($sql))
|
||||
echo '<script>alert("删除成功!");window.location.href="/admin/sou.php";</script>';
|
||||
else
|
||||
echo '<script>alert("删除失败!");history.go(-1);</script>';
|
||||
|
@ -205,8 +206,9 @@ echo '<div class="alert alert-info">系统共有 <b>'.$sousrows.'</b> 个搜索
|
|||
<thead><tr><th>排序权重</th><th>名称</th><th>别名</th><th>地址</th><th>状态</th><th>操作</th></tr></thead>
|
||||
<tbody>';
|
||||
|
||||
$rs=mysqli_query($con,"SELECT * FROM `lylme_sou` ORDER BY `lylme_sou`.`sou_order` ASC");
|
||||
while($res = mysqli_fetch_array($rs))
|
||||
|
||||
$rs=$DB->query("SELECT * FROM `lylme_sou` ORDER BY `lylme_sou`.`sou_order` ASC");
|
||||
while($res = $DB->fetch($rs))
|
||||
{
|
||||
echo '<tr><td><b>'.$res['sou_order'].'</b></td><td><b><font color="'.$res['sou_color'].'">'.$res['sou_name'].'</font></b></td><td>'.$res['sou_alias'].'</td><td>'.$res['sou_link'].'</td><td>';
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
$title = '导航菜单管理';
|
||||
include './head.php';
|
||||
$tagsrows=mysqli_num_rows(mysqli_query($con, "SELECT * FROM `lylme_tags`"));
|
||||
$tagsrows = $DB->num_rows($DB->query("SELECT * FROM `lylme_tags`"));
|
||||
?>
|
||||
<main class="lyear-layout-content">
|
||||
|
||||
|
@ -12,11 +12,8 @@ $tagsrows=mysqli_num_rows(mysqli_query($con, "SELECT * FROM `lylme_tags`"));
|
|||
<div class="card">
|
||||
<div class="card-body">
|
||||
<?php
|
||||
|
||||
$set = isset($_GET['set']) ? $_GET['set'] : null;
|
||||
|
||||
if($set=='add')
|
||||
{
|
||||
if ($set == 'add') {
|
||||
echo '<h4>新增导航菜单链接</h4>
|
||||
<div class="panel-body">
|
||||
<form action="./tag.php?set=add_submit" method="POST">
|
||||
|
@ -39,12 +36,10 @@ echo '<h4>新增导航菜单链接</h4>
|
|||
</div>
|
||||
<br/><a href="./tag.php"><<返回</a>
|
||||
</div></div>';
|
||||
}
|
||||
elseif($set=='edit')
|
||||
{
|
||||
} elseif ($set == 'edit') {
|
||||
$id = $_GET['id'];
|
||||
$row2 = mysqli_query($con,"select * from lylme_tags where tag_id='$id' limit 1");
|
||||
$row=mysqli_fetch_assoc($row2);
|
||||
$row2 = $DB->query("select * from lylme_tags where tag_id='$id' limit 1");
|
||||
$row = $DB->fetch($row2);
|
||||
echo '<h4>修改导航菜单链接</h4>
|
||||
<div class="panel-body">
|
||||
<form action="./tag.php?set=edit_submit&id=' . $id . '" method="POST">
|
||||
|
@ -62,7 +57,8 @@ echo '<h4>修改导航菜单链接</h4>
|
|||
<option value="0">0. 当前窗口打开</option>
|
||||
<option ';
|
||||
if ($row['tag_target'] == 1) {
|
||||
echo 'selected="selected"';}
|
||||
echo 'selected="selected"';
|
||||
}
|
||||
echo 'value="1">1. 新窗口打开</option>
|
||||
</select></div>
|
||||
<div class="form-group">
|
||||
|
@ -70,69 +66,56 @@ echo 'value="1">1. 新窗口打开</option>
|
|||
</div>
|
||||
<br/><a href="./tag.php"><<返回</a>
|
||||
</div></div>';
|
||||
}
|
||||
elseif($set=='add_submit')
|
||||
{
|
||||
} elseif ($set == 'add_submit') {
|
||||
$name = $_POST['name'];
|
||||
|
||||
$link = $_POST['link'];
|
||||
if($_POST['target']==true){$target=1;}else{$target=0;}
|
||||
if ($_POST['target'] == true) {
|
||||
$target = 1;
|
||||
} else {
|
||||
$target = 0;
|
||||
}
|
||||
if ($name == NULL or $link == NULL) {
|
||||
echo '<script>alert("保存错误,请确保带星号的都不为空!");history.go(-1);</script>';
|
||||
} else {
|
||||
$sql = "INSERT INTO `lylme_tags` (`tag_id`, `tag_name`, `tag_link`, `tag_target`) VALUES (NULL, '" . $name . "', '" . $link . "', '" . $target . "');";
|
||||
|
||||
if(mysqli_query($con,$sql)){
|
||||
if ($DB->query($sql)) {
|
||||
echo '<script>alert("添加导航菜单 ' . $name . ' 成功!");window.location.href="/admin/tag.php";</script>';
|
||||
}else
|
||||
echo '<script>alert("添加导航菜单失败");history.go(-1);</script>';
|
||||
} else echo '<script>alert("添加导航菜单失败");history.go(-1);</script>';
|
||||
}
|
||||
}
|
||||
elseif($set=='edit_submit')
|
||||
{
|
||||
} elseif ($set == 'edit_submit') {
|
||||
$id = $_GET['id'];
|
||||
$rows2 = mysqli_query($con,"select * from lylme_tags where tag_id='$id' limit 1");
|
||||
$rows=mysqli_fetch_assoc($rows2);
|
||||
if(!$rows)
|
||||
echo '<script>alert("当前记录不存在!");history.go(-1);</script>';
|
||||
$rows2 = $DB->query("select * from lylme_tags where tag_id='$id' limit 1");
|
||||
$rows = $DB->fetch($rows2);
|
||||
if (!$rows) echo '<script>alert("当前记录不存在!");history.go(-1);</script>';
|
||||
$name = $_POST['name'];
|
||||
$link = $_POST['link'];
|
||||
if($_POST['target']==true){$target=1;}else{$target=0;}
|
||||
|
||||
if ($_POST['target'] == true) {
|
||||
$target = 1;
|
||||
} else {
|
||||
$target = 0;
|
||||
}
|
||||
if ($name == NULL or $link == NULL) {
|
||||
echo '<script>alert("保存错误,请确保带星号的都不为空!");history.go(-1);</script>';
|
||||
} else {
|
||||
$sql = "UPDATE `lylme_tags` SET `tag_name` = '" . $name . "', `tag_link` = '" . $link . "', `tag_target` = '" . $target . "' WHERE `lylme_tags`.`tag_id` = " . $id . ";";
|
||||
if(mysqli_query($con,$sql))
|
||||
echo '<script>alert("修改导航菜单 '.$name.' 成功!");window.location.href="/admin/tag.php";</script>';
|
||||
else
|
||||
echo '<script>alert("修改导航菜单失败!");history.go(-1);</script>';
|
||||
if ($DB->query($sql)) echo '<script>alert("修改导航菜单 ' . $name . ' 成功!");window.location.href="/admin/tag.php";</script>';
|
||||
else echo '<script>alert("修改导航菜单失败!");history.go(-1);</script>';
|
||||
}
|
||||
}
|
||||
elseif($set=='delete')
|
||||
{
|
||||
} elseif ($set == 'delete') {
|
||||
$id = $_GET['id'];
|
||||
$sql = "DELETE FROM lylme_tags WHERE tag_id='$id'";
|
||||
if(mysqli_query($con,$sql))
|
||||
echo '<script>alert("删除成功!");window.location.href="/admin/tag.php";</script>';
|
||||
else
|
||||
echo '<script>alert("删除失败!");history.go(-1);</script>';
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
|
||||
if ($DB->query($sql)) echo '<script>alert("删除成功!");window.location.href="/admin/tag.php";</script>';
|
||||
else echo '<script>alert("删除失败!");history.go(-1);</script>';
|
||||
} else {
|
||||
echo '<div class="alert alert-info">系统共有 <b>' . $tagsrows . '</b> 个导航菜单<br/><a href="./tag.php?set=add" class="btn btn-primary">新增导航菜单</a></div>';
|
||||
|
||||
?>
|
||||
<div class="table-responsive">
|
||||
<table class="table table-striped">
|
||||
<thead><tr><th>名称</th><th>链接</th><th>操作</th></tr></thead>
|
||||
<tbody>
|
||||
<?php
|
||||
$rs=mysqli_query($con,"SELECT * FROM `lylme_tags`");
|
||||
while($res = mysqli_fetch_array($rs))
|
||||
{
|
||||
$rs = $DB->query("SELECT * FROM `lylme_tags`");
|
||||
while ($res = $DB->fetch($rs)) {
|
||||
echo '<tr><td>' . $res['tag_name'] . '</td><td>' . $res['tag_link'] . '</td><td><a href="./tag.php?set=edit&id=' . $res['tag_id'] . '" class="btn btn-info btn-xs">编辑</a> <a href="./tag.php?set=delete&id=' . $res['tag_id'] . '" class="btn btn-xs btn-danger" onclick="return confirm(\'确定删除 ' . $res['tag_name'] . ' ?\');">删除</a></td></tr>';
|
||||
}
|
||||
?>
|
||||
|
@ -149,8 +132,6 @@ echo '<tr><td>'.$res['tag_name'].'</td><td>'.$res['tag_link'].'</td><td><a href=
|
|||
|
||||
</main>
|
||||
<?php
|
||||
|
||||
}
|
||||
|
||||
include './footer.php';
|
||||
?>
|
Loading…
Reference in New Issue