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 = '