Reindent user/index.php and include search

This commit is contained in:
Felix Albrigtsen 2023-02-23 17:08:53 +01:00
parent c4e7d15c37
commit 0b2ef1a4f8
1 changed files with 63 additions and 56 deletions

View File

@ -1,8 +1,7 @@
<?php <?php
include("../db_connect.php");
include("../db_connect.php"); if (isset($_GET['username'])) {
if (isset($_GET['username'])) {
$query = pg_prepare($dbconn, "userid_by_username", 'SELECT id FROM users WHERE username = $1'); $query = pg_prepare($dbconn, "userid_by_username", 'SELECT id FROM users WHERE username = $1');
$result = pg_execute($dbconn, "userid_by_username", array($_GET['username'])); $result = pg_execute($dbconn, "userid_by_username", array($_GET['username']));
$row = pg_fetch_row($result); $row = pg_fetch_row($result);
@ -13,8 +12,7 @@ if (isset($_GET['username'])) {
} else { } else {
header("Location: /user/index.php?id=-1"); header("Location: /user/index.php?id=-1");
} }
} }
?> ?>
<!DOCTYPE html> <!DOCTYPE html>
@ -31,7 +29,6 @@ if (isset($_GET['username'])) {
?> ?>
<div class="container box"> <div class="container box">
<div class="notification is-primary"> <div class="notification is-primary">
<h1 class="title">Search and edit users</h1> <h1 class="title">Search and edit users</h1>
</div> </div>
@ -50,7 +47,11 @@ if (isset($_GET['username'])) {
</form> </form>
</div> </div>
<table class="table is-fullwidth"> <div class="notiifcation is-info is-light mt-2">
<input class="input" type="text" id="searchInput" placeholder="Search user">
</div>
<table class="table is-fullwidth" id="userTable">
<thead> <thead>
<tr> <tr>
<th>Username</th> <th>Username</th>
@ -77,7 +78,13 @@ if (isset($_GET['username'])) {
} }
?> ?>
</tbody> </tbody>
</table>
</div>
<?php
// The site functions entirely without JavaScript, but it's nice to have search without reloading the page
?>
<script src="/js/fuse.js"></script>
<script src="/js/searchUserTable.js"></script>
</body> </body>
</html> </html>