From 8921fe38c8f119d447aa34b13c3e0262728c458f Mon Sep 17 00:00:00 2001 From: printempw Date: Sun, 27 Mar 2016 10:55:16 +0800 Subject: [PATCH] added user search --- admin/manage.php | 5 +++-- assets/css/admin.style.css | 11 ++++++++++- templates/admin/list.tpl.php | 20 +++++++++++++++----- 3 files changed, 28 insertions(+), 8 deletions(-) diff --git a/admin/manage.php b/admin/manage.php index 5191091f..781c79a2 100644 --- a/admin/manage.php +++ b/admin/manage.php @@ -3,7 +3,7 @@ * @Author: printempw * @Date: 2016-03-06 14:19:20 * @Last Modified by: printempw - * @Last Modified time: 2016-03-27 09:45:54 + * @Last Modified time: 2016-03-27 10:53:06 */ require "../libraries/session.inc.php"; if (!$user->is_admin) header('Location: ../index.php?msg=看起来你并不是管理员'); @@ -17,7 +17,6 @@ if (isset($_GET['show'])) { } $data['script'] = <<< 'EOT' - EOT; +if (isset($_GET['show'])) + $data['script'] .= ''; View::show('footer', $data); ?> diff --git a/assets/css/admin.style.css b/assets/css/admin.style.css index 6d7a5cee..393b9544 100644 --- a/assets/css/admin.style.css +++ b/assets/css/admin.style.css @@ -2,7 +2,7 @@ * @Author: printempw * @Date: 2016-02-04 16:47:54 * @Last Modified by: printempw -* @Last Modified time: 2016-03-27 09:40:35 +* @Last Modified time: 2016-03-27 10:38:36 */ @import url(https://fonts.googleapis.com/css?family=Ubuntu); @@ -56,3 +56,12 @@ td[class='key'], td[class='value'] { border-radius: 15px; outline: none; } +.user-search-form { + display: inline; +} +.user-search-input { + display: inline; + width: 30%; + float: right; + margin: 0; +} diff --git a/templates/admin/list.tpl.php b/templates/admin/list.tpl.php index 69edc68e..c08fda4b 100644 --- a/templates/admin/list.tpl.php +++ b/templates/admin/list.tpl.php @@ -5,6 +5,9 @@

用户管理 User Manage +
+ +

@@ -27,8 +30,14 @@ query("SELECT * FROM users ORDER BY `uid` LIMIT ".(string)(($page_now-1)*30).", 30"); - $page_total = round($db->getRecordNum()/30); + + if (isset($_POST['search-username'])) { + $result = $db->query("SELECT * FROM users WHERE `username` LIKE '%".$_POST['search-username']."%' ORDER BY `uid` LIMIT ".(string)(($page_now-1)*30).", 30"); + } else { + $result = $db->query("SELECT * FROM users ORDER BY `uid` LIMIT ".(string)(($page_now-1)*30).", 30"); + } + + $page_total = round($result->num_rows/30); while ($row = $result->fetch_array()) { ?> @@ -62,13 +71,13 @@ + +