add rudimentary search
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
function selectSomeUsers($db, $n) {
|
function select20UsersFromN($db, $n) {
|
||||||
return $db->query("
|
return $db->query("
|
||||||
SELECT
|
SELECT
|
||||||
`userID`,
|
`userID`,
|
||||||
@@ -10,10 +10,35 @@ function selectSomeUsers($db, $n) {
|
|||||||
FROM
|
FROM
|
||||||
`user`
|
`user`
|
||||||
ORDER BY
|
ORDER BY
|
||||||
|
`role`,
|
||||||
`username`
|
`username`
|
||||||
LIMIT
|
LIMIT
|
||||||
$n
|
$n, 20
|
||||||
");
|
");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function search20UsersFromN($db, $n, $keyword) {
|
||||||
|
$q = $db->prepare("
|
||||||
|
SELECT
|
||||||
|
`userID`,
|
||||||
|
`username`,
|
||||||
|
`role`,
|
||||||
|
`bancomment`
|
||||||
|
FROM
|
||||||
|
`user`
|
||||||
|
WHERE
|
||||||
|
`username` LIKE :keyword
|
||||||
|
ORDER BY
|
||||||
|
`username`
|
||||||
|
LIMIT
|
||||||
|
:n, 20
|
||||||
|
");
|
||||||
|
|
||||||
|
$keyword = "%$keyword%";
|
||||||
|
$q->bindParam(':keyword', $keyword);
|
||||||
|
$q->bindParam(':n', $n, PDO::PARAM_INT);
|
||||||
|
$q->execute();
|
||||||
|
return $q;
|
||||||
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|||||||
@@ -20,11 +20,14 @@
|
|||||||
|
|
||||||
<!-- function test_input taken from http://www.w3schools.com/php/php_form_validation.asp -->
|
<!-- function test_input taken from http://www.w3schools.com/php/php_form_validation.asp -->
|
||||||
<?php
|
<?php
|
||||||
$search = $pagetype = "";
|
$search = $pagetype = $searchvalue = "";
|
||||||
|
$listnr = 0;
|
||||||
$status = array();
|
$status = array();
|
||||||
|
|
||||||
if ($_SERVER["REQUEST_METHOD"] == "POST") {
|
if ($_SERVER["REQUEST_METHOD"] == "POST") {
|
||||||
$search = test_input($_POST["search"]);
|
if (!empty($_POST["search"])) {
|
||||||
|
$search = $searchvalue = test_input($_POST["search"]);
|
||||||
|
}
|
||||||
|
|
||||||
if (!empty($_POST["pagetype"])) {
|
if (!empty($_POST["pagetype"])) {
|
||||||
$pagetype = test_input($_POST["pagetype"]);
|
$pagetype = test_input($_POST["pagetype"]);
|
||||||
@@ -112,7 +115,6 @@ function test_input($data) {
|
|||||||
<input type="submit" name="next" value="next">
|
<input type="submit" name="next" value="next">
|
||||||
</div> <br>
|
</div> <br>
|
||||||
|
|
||||||
|
|
||||||
<table class="usertable">
|
<table class="usertable">
|
||||||
<tr>
|
<tr>
|
||||||
<th class="table-checkbox">
|
<th class="table-checkbox">
|
||||||
@@ -125,7 +127,8 @@ function test_input($data) {
|
|||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
$q = selectSomeUsers($db, 20);
|
$q = search20UsersFromN($db, $listnr, $searchvalue);
|
||||||
|
|
||||||
while($user = $q->fetch(PDO::FETCH_ASSOC)) {
|
while($user = $q->fetch(PDO::FETCH_ASSOC)) {
|
||||||
$userID = $user['userID'];
|
$userID = $user['userID'];
|
||||||
$username = $user['username'];
|
$username = $user['username'];
|
||||||
@@ -158,46 +161,11 @@ function test_input($data) {
|
|||||||
");
|
");
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<!-- <tr>
|
|
||||||
<td><input type="checkbox" name="check1"></td>
|
|
||||||
<td>John Smith</td>
|
|
||||||
<td>Banned</td>
|
|
||||||
<td>unregulated time travel</td>
|
|
||||||
<td>
|
|
||||||
<form class="admin-useraction"
|
|
||||||
action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>"
|
|
||||||
method="post">
|
|
||||||
<select class="action" name="actions">
|
|
||||||
<option value="freeze">Freeze</option>
|
|
||||||
<option value="ban">Ban</option>
|
|
||||||
<option value="restore">Restore</option>
|
|
||||||
</select>
|
|
||||||
<input type="submit" value="Confirm">
|
|
||||||
</form>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td><input type="checkbox" name="check1"></td>
|
|
||||||
<td>poey jokeaim</td>
|
|
||||||
<td>Banned</td>
|
|
||||||
<td>l33t h4xx</td>
|
|
||||||
<td>
|
|
||||||
<form class="admin-useraction"
|
|
||||||
action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>"
|
|
||||||
method="post">
|
|
||||||
<select class="action" name="actions">
|
|
||||||
<option value="freeze">Freeze</option>
|
|
||||||
<option value="ban">Ban</option>
|
|
||||||
<option value="restore">Restore</option>
|
|
||||||
</select>
|
|
||||||
<input type="submit" value="Confirm">
|
|
||||||
</form>
|
|
||||||
</td>
|
|
||||||
</tr> -->
|
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
|
<pre><?php print_r($_POST); ?></pre>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
|
|||||||
Reference in New Issue
Block a user