<?php 

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

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

$section = clean($_POST['section']);
$offset = (int)$_POST['offset'];

switch($section){

   case 'completed':
   $sql = "SELECT * FROM orders WHERE status = 'completed' ORDER BY id DESC ";
   break;

   case 'pending':
   $sql = "SELECT * FROM orders WHERE status = 'pending' ORDER BY id DESC ";
   break;

   case 'canceled':
   $sql = "SELECT * FROM orders WHERE status = 'canceled' ORDER BY id DESC ";
   break;

   default:
   $sql = "SELECT * FROM orders WHERE status = 'Completed' ORDER BY id DESC ";
   break;

}

$sql .= "LIMIT $offset, {$per['orders']}";

fetch_elements($sql, 'admin/elements/orders/main.php', 'x'); ?>