$sb, 'o' => $o))); $sql = mysqli_query($mysqli,"SELECT SQL_CALC_FOUND_ROWS * FROM accounts, revenues, categories WHERE revenues.account_id = accounts.account_id AND revenues.category_id = categories.category_id AND revenues.company_id = $session_company_id AND (account_name LIKE '%$q%' OR revenue_payment_method LIKE '%$q%' OR category_name LIKE '%$q%' OR revenue_reference LIKE '%$q%' OR revenue_amount LIKE '%$q%') AND DATE(revenue_date) BETWEEN '$dtf' AND '$dtt' ORDER BY $sb $o LIMIT $record_from, $record_to"); $num_rows = mysqli_fetch_row(mysqli_query($mysqli,"SELECT FOUND_ROWS()")); ?>