<?php 

$dir = '../../';

require_once $dir.'includes/main.php';

$section = clean($_POST['section']);
$input = clean($_POST['input']);

switch($section){

   case 'points':
      $sql = "SELECT * FROM listings WHERE status != 'pending' AND name LIKE '{$input}%' ORDER BY points DESC ";
      $include = 'listings/main.php';
      break;

   case 'fresh':
      $sql = "SELECT * FROM listings WHERE status != 'pending' AND name LIKE '{$input}%' ORDER BY id DESC ";
      $include = 'listings/main.php';
      break;

   case 'active':
      $sql = "SELECT * FROM listings WHERE status != 'pending' AND name LIKE '{$input}%' ORDER BY last_click DESC ";
      $include = 'listings/main.php';
      break;

   case 'inactive':
      $sql = "SELECT * FROM listings WHERE status != 'pending' AND name LIKE '{$input}%' AND points = 0 ORDER BY id DESC ";
      $include = 'listings/main.php';
      break;

   default:
      $sql = "SELECT * FROM listings WHERE status != 'pending' AND name LIKE '{$input}%' ORDER BY points DESC ";
      $include = 'listings/main.php';
      break;

}

$sql .= "LIMIT {$per['listings']}";

fetch_elements($sql, 'admin/elements/'.$include, 'a');

?>