Marijn button #99
@@ -80,6 +80,55 @@ function search20GroupsFromNByStatus($db, $n, $keyword, $status) {
|
|||||||
return $q;
|
return $q;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function searchSomeGroupsByStatus($db, $n, $m, $keyword, $status) {
|
||||||
|
$q = $db->prepare("
|
||||||
|
SELECT
|
||||||
|
`groupID`,
|
||||||
|
`name`,
|
||||||
|
`status`,
|
||||||
|
`description`
|
||||||
|
FROM
|
||||||
|
`group_page`
|
||||||
|
WHERE
|
||||||
|
`name` LIKE :keyword AND
|
||||||
|
FIND_IN_SET (`status`, :statuses)
|
||||||
|
ORDER BY
|
||||||
|
`name`
|
||||||
|
LIMIT
|
||||||
|
:n, :m
|
||||||
|
");
|
||||||
|
|
||||||
|
$keyword = "%$keyword%";
|
||||||
|
$q->bindParam(':keyword', $keyword);
|
||||||
|
$q->bindParam(':n', $n, PDO::PARAM_INT);
|
||||||
|
$q->bindParam(':m', $m, PDO::PARAM_INT);
|
||||||
|
$statuses = implode(',', $status);
|
||||||
|
$q->bindParam(':statuses', $statuses);
|
||||||
|
$q->execute();
|
||||||
|
return $q;
|
||||||
|
}
|
||||||
|
|
||||||
|
function countSomeGroupsByStatus($db, $keyword, $status) {
|
||||||
|
$q = $db->prepare("
|
||||||
|
SELECT
|
||||||
|
COUNT(*)
|
||||||
|
FROM
|
||||||
|
`group_page`
|
||||||
|
WHERE
|
||||||
|
`name` LIKE :keyword AND
|
||||||
|
FIND_IN_SET (`status`, :statuses)
|
||||||
|
ORDER BY
|
||||||
|
`name`
|
||||||
|
");
|
||||||
|
|
||||||
|
$keyword = "%$keyword%";
|
||||||
|
$q->bindParam(':keyword', $keyword);
|
||||||
|
$statuses = implode(',', $status);
|
||||||
|
$q->bindParam(':statuses', $statuses);
|
||||||
|
$q->execute();
|
||||||
|
return $q;
|
||||||
|
}
|
||||||
|
|
||||||
function changeGroupStatusByID($db, $id, $status) {
|
function changeGroupStatusByID($db, $id, $status) {
|
||||||
$q = $db->query("
|
$q = $db->query("
|
||||||
UPDATE
|
UPDATE
|
||||||
|
|||||||
@@ -62,8 +62,6 @@
|
|||||||
<!-- 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 = "";
|
$search = "";
|
||||||
$listn = 0; // TODO: add page functionality
|
|
||||||
$listm = 20;
|
|
||||||
$currentpage = 1;
|
$currentpage = 1;
|
||||||
$perpage = 20;
|
$perpage = 20;
|
||||||
$status = $groupstatus = array();
|
$status = $groupstatus = array();
|
||||||
@@ -109,6 +107,9 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$listn = ($currentpage-1) * $perpage;
|
||||||
|
$listm = $currentpage * $perpage;
|
||||||
|
|
||||||
function test_input($data) {
|
function test_input($data) {
|
||||||
$data = trim($data);
|
$data = trim($data);
|
||||||
$data = stripslashes($data);
|
$data = stripslashes($data);
|
||||||
@@ -224,7 +225,12 @@ function test_input($data) {
|
|||||||
|
|
||||||
<div class="admin-userpage">
|
<div class="admin-userpage">
|
||||||
<p class="pagenumber">Showing results
|
<p class="pagenumber">Showing results
|
||||||
<?php $pages = countSomeUsersByStatus($db, $search, $status);
|
<?php
|
||||||
|
if ($pagetype == "user") {
|
||||||
|
$pages = countSomeUsersByStatus($db, $search, $status);
|
||||||
|
} else {
|
||||||
|
$pages = countSomeGroupsByStatus($db, $search, $status);
|
||||||
|
}
|
||||||
$countresults = $pages->fetchColumn();
|
$countresults = $pages->fetchColumn();
|
||||||
$mincount = min($listm, $countresults);
|
$mincount = min($listm, $countresults);
|
||||||
echo "$listn to $mincount out of $countresults"; ?></p><br>
|
echo "$listn to $mincount out of $countresults"; ?></p><br>
|
||||||
@@ -237,7 +243,7 @@ function test_input($data) {
|
|||||||
onchange="this.form.submit()"
|
onchange="this.form.submit()"
|
||||||
value="">
|
value="">
|
||||||
<?php
|
<?php
|
||||||
for ($i=1; $i <= $countresults / $perpage + 1; $i++) {
|
for ($i=1; $i <= ceil($countresults / $perpage); $i++) {
|
||||||
if ($currentpage == $i) {
|
if ($currentpage == $i) {
|
||||||
echo "<option value='$i' selected>$i</option>";
|
echo "<option value='$i' selected>$i</option>";
|
||||||
} else {
|
} else {
|
||||||
@@ -263,8 +269,8 @@ function test_input($data) {
|
|||||||
|
|
||||||
<!-- Table construction via php PDO. -->
|
<!-- Table construction via php PDO. -->
|
||||||
<?php
|
<?php
|
||||||
$listn = ($currentpage-1) * 20;
|
$listn = ($currentpage-1) * $perpage;
|
||||||
$listm = $currentpage * 20;
|
$listm = $currentpage * $perpage;
|
||||||
|
|
||||||
if ($pagetype == 'user') {
|
if ($pagetype == 'user') {
|
||||||
$q = searchSomeUsersByStatus($db, $listn, $listm, $search, $status);
|
$q = searchSomeUsersByStatus($db, $listn, $listm, $search, $status);
|
||||||
@@ -305,7 +311,7 @@ function test_input($data) {
|
|||||||
");
|
");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$q = search20GroupsFromNByStatus($db, $listn, $search, $groupstatus);
|
$q = searchSomeGroupsByStatus($db, $listn, $listm, $search, $groupstatus);
|
||||||
|
|
||||||
while ($group = $q->fetch(PDO::FETCH_ASSOC)) {
|
while ($group = $q->fetch(PDO::FETCH_ASSOC)) {
|
||||||
$groupID = $group['groupID'];
|
$groupID = $group['groupID'];
|
||||||
|
|||||||
Reference in New Issue
Block a user