<h1 class='cat_heading'>> chosen file type: image<br>&nbsp;&nbsp;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>
  <label for='submit'> </label>
  <input type='submit' name='submit'  value='&nbsp;filter&nbsp;'></input>
</form>

<?php
  include_once('../app/db_connector.php');

  if( isset($_POST['sel_order']) && isset($_POST['inp_search']) ) {
    $sort = 'img_date'; 
    $sdir = 'DESC';
    
    switch($_POST['sel_order']) {
      case 'new':
        break;
      case 'old':
        $sdir = 'ASC';
        break;
      case 'az':
        $sort = 'img_title';
        $sdir = 'ASC';
        break;
      case 'za':
        $sort = 'img_title';
        break;
      default:
        break;
    }
      
    get_images($pdo, $_POST['inp_search'], $sort, $sdir);
  }
  else {
    get_images($pdo);
  }
?>

