<?php
 include("pageControler.php");
require_once "db.php";
if (isset($_GET['term']) and $_GET['mod']=='customerName') {
     
    $sql = "SELECT * FROM customers WHERE name LIKE '%{$_GET['term']}%' or id LIKE '%{$_GET['term']}'    limit 10 ";
    $query = $db ->query($sql);
    if (mysqli_num_rows($query) > 0) {
     while ($user =  $query ->fetch_array()) {
      $name= $user['name'];
      $id= $user['id'];
	  $fullName=$id."-".$name;
      $res[] = $fullName;
     }
    } else {
      $res = array();
    }
    //return json res
	
    echo json_encode($res);
	 
}
 
 if (isset($_GET['term']) and $_GET['mod']=='s_customerName') {
     
    $sql = "SELECT * FROM customers WHERE name LIKE '%{$_GET['term']}%' or id LIKE '%{$_GET['term']}'    limit 10 ";
    $query = $db ->query($sql);
    if (mysqli_num_rows($query) > 0) {
     while ($user =  $query ->fetch_array()) {
      $name= $user['name'];
      $id= $user['id'];
	  $fullName=$id."-".$name;
      $res[] = $fullName;
     }
    } else {
      $res = array();
    }
    //return json res
	
    echo json_encode($res);
	 
}
 
?>