-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsearch.php
127 lines (126 loc) · 3.21 KB
/
search.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
<?php
session_start();
$_SESSION['username']=!empty($_SESSION['username']) ? $_SESSION['username'] : null;
if ($_SESSION['username']==""){
header("Location:login.php");
}
//验证搜索词
if(isset($_GET['search']))
{
$ser=$_GET['search'];
}
else
{
$ser='';
}
//验证page
if(isset($_GET['page'])&&is_numeric($_GET['page']))
{
$page=intval($_GET['page']);
}
else
{
$page=1;
}
include_once 'conn.php';
mysql_query("SET NAMES 'utf8'");
mysql_query("SET CHARACTER_SET_CLIENT=utf8");
mysql_query("SET CHARACTER_SET_RESULTS=utf8");
//每页显示数据
$num=11;
$sql_search="select * from `filelist` where `filename` like '%" . $ser . "%'";
$total=mysql_num_rows(mysql_query($sql_search));
$pagenum=ceil($total/$num);
//假如传入的页数参数apge 大于总页数 pagenum,则显示错误信息
if($page>$pagenum || $page <= 0)
{
header("Location:search.php");
}
//(传入的页数-1) * 每页的数据 得到limit第一个参数的值
$offset=($page-1)*$num;
//获取相应页数所需要显示的数据
$info=mysql_query( $sql_search . " order by `diskname` DESC limit $offset,$num");
while($it=mysql_fetch_array($info))
{
$tem[]=array('http://'.$it['host'].'/pic/'.$it['diskname'],$it['filename'],$it['diskname']);
}
//分页信息
$pre=$page-1;
$nex=$page+1;
?>
<!DOCTYPE HTML>
<head>
<html xmlns="http://www.w3.org/1999/xhtml">
<meta charset="UTF-8" />
<title>SAIMG图片管理</title>
<link rel="shortcut icon" href="/images/favicon.ico"/>
<link rel="stylesheet" href="saimgcon.css" type="text/css"/>
<script type="text/javascript" src="js/jq.js"></script>
<script type="text/javascript">
$(document).ready(function(){
/**
* 删除一张图片
*/
$(".item_del").live("click",function(){
var v_mid=$(this).attr("id");
var tem_this=$(this);
$.ajax({
url:"delpic.php",
type:'post',
data:{id:v_mid},
dataType:'json',
success:function(resp){
if(resp['status']=="yes")
{
tem_this.parent().remove();
}
else
{
alert(resp['msg']);
}
}
});
});
});
</script>
</head>
<body>
<!--header-->
<div id="header">
<div class="headbtn">
<a id="head_man" href="index.php">上传图片</a>
</div>
<div class="headbtn">
<a href="loginout.php">退出登录</a>
</div>
<form id="saimgser" method="get" action="/search.php">
<input id="sercon" type="text" value="" name="search">
<input id="serbtn" type="submit" value="搜索">
</form>
</div>
<div id="picbox">
<?php foreach($tem as $item):?>
<div class="picitem">
<img src="<?php echo $item[0]?>">
<input type="text" value="<?php echo $item[0]?>"/>
<span>图片名称:<?php echo $item[1];?></span>
<a class="item_del" id="<?php echo $item[2];?>" href="javascript:void(0);">删除</a>
</div>
<?php endforeach;?>
<div id="pagenav">
<?php
if($pre>=1)
{
$prepage="<a style=\"float:left;\" href=\"search.php?page=$pre&search=$ser\">上一页</a>";
echo $prepage;
}
if($nex<=$pagenum)
{
$nexpage="<a style=\"float:right;\" href=\"search.php?page=$nex&search=$ser\">下一页</a>";
echo $nexpage;
}
?>
</div>
</div>
</body>
</html>