ADD: database utility toolbar added to image page, search worx, order does not yet
This commit is contained in:
parent
aa0dd82856
commit
ba6eefbbab
@ -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 = '<ul class="img_list">';
|
||||
|
@ -1,7 +1,46 @@
|
||||
<h1 class='cat_heading'>> chosen file type: image<br> listing files...</h1>
|
||||
|
||||
<form class='db_utilities' method='POST'>
|
||||
<label for='sel_order'>order by</label>
|
||||
<select name='sel_order' id='sel_order'>
|
||||
<option value='new'>newest</option>
|
||||
<option value='old'>oldest</option>
|
||||
<option value='az'>A - Z</option>
|
||||
<option value='za'>Z -A</option>
|
||||
</select>
|
||||
<label for='inp_search'>search</label>
|
||||
<input type='search' name='inp_search' id='inp_search'></input>
|
||||
<input type='submit' value='filter'></input>
|
||||
</form>
|
||||
|
||||
<?php
|
||||
include_once('../app/db_connector.php');
|
||||
|
||||
if( isset($_POST['sel_order']) && isset($_POST['inp_search']) ) {
|
||||
$sort = 'date';
|
||||
$sdir = 'DESC';
|
||||
var_dump($sort, $sdir);
|
||||
switch($_POST['sel_order']) {
|
||||
case 'new':
|
||||
break;
|
||||
case 'old':
|
||||
$sdir = 'ASC';
|
||||
break;
|
||||
case 'az':
|
||||
$sort = 'img_name';
|
||||
$sdir = 'ASC';
|
||||
break;
|
||||
case 'za':
|
||||
$sort = 'img_name';
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
get_images($pdo, $_POST['inp_search'], $sort, $sdir);
|
||||
}
|
||||
else {
|
||||
get_images($pdo);
|
||||
}
|
||||
?>
|
||||
|
||||
|
@ -67,6 +67,7 @@
|
||||
<p class='footer_element'>
|
||||
<a href='./index.php?el=legal'>legal information</a>
|
||||
<a href='./index.php?el=privacy'>privacy policy</a>
|
||||
<a href='./index.php?el=contact'>contact</a>
|
||||
</p>
|
||||
<p class='footer_element'><a href='https://layer-8.moe/'>layer-8.moe</a> is a non-commercial homepage created by a private individual in 2024</p>
|
||||
<p class='footer_element'>
|
||||
|
@ -138,3 +138,7 @@ footer {
|
||||
padding: 1rem;
|
||||
padding-left: 5rem;
|
||||
}
|
||||
|
||||
.db_utilities {
|
||||
padding: 2rem;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user