From ba6eefbbabb2b8313fff2146444993d292e2311f Mon Sep 17 00:00:00 2001 From: TheShinyMelon Date: Sat, 16 Nov 2024 22:00:15 +0100 Subject: [PATCH] ADD: database utility toolbar added to image page, search worx, order does not yet --- app/db_connector.php | 7 +++--- public/image.php | 41 ++++++++++++++++++++++++++++++++- public/index.php | 3 ++- public/resources/stylesheet.css | 4 ++++ 4 files changed, 50 insertions(+), 5 deletions(-) diff --git a/app/db_connector.php b/app/db_connector.php index d058807..734b7a2 100755 --- a/app/db_connector.php +++ b/app/db_connector.php @@ -8,9 +8,10 @@ echo $e->getMessage(); } -function get_images($pdo) { - $stmt = $pdo->prepare("SELECT * FROM images;"); - $stmt->execute(); +function get_images($pdo, $search='%', $sort='img_date', $sdir='DESC') { + $params = array('search' => $search, 'sort' => $sort, 'sdir' => $sdir); + $stmt = $pdo->prepare("SELECT * FROM images WHERE img_title LIKE CONCAT('%', :search ,'%') ORDER BY :sort :sdir;"); + $stmt->execute($params); $data = $stmt->fetchAll(); $img_list = '