<?php 

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

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

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

switch($section){

   case 'active':
      $sql = "SELECT * FROM users WHERE username LIKE '{$input}%' ORDER BY last_seen DESC";
      break;

  case 'purchased':
      $sql = "SELECT * FROM users WHERE orders > 0 AND username LIKE '{$input}%' ORDER BY orders DESC";
      break;

  case 'points':
      $sql = "SELECT * FROM users WHERE username LIKE '{$input}%' ORDER BY points DESC";
      break;

  case 'visits':
      $sql = "SELECT * FROM users WHERE username LIKE '{$input}%' ORDER BY visits DESC";
      break;

  default:
      $sql = "SELECT * FROM users WHERE username LIKE '{$input}%' ORDER BY last_seen DESC";
      break;

}

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

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

?>