forked from sahujaunpuri/smart_retail
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathget_customer_names.php
executable file
·50 lines (35 loc) · 1.01 KB
/
get_customer_names.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<?php
//require database connection and session varibales
require_once './includes/class.dbc.php';
require_once './includes/functions.php';
//create an instance of the database connection
$db = new dbc();
$dbc = $db->connect();
//Grab the member_id
$customer_name = filter($_POST['key']);
$names = [];
$query = "SELECT `sales_agent` FROM `sales_ref`
WHERE `sales_agent` LIKE '%$customer_name%' GROUP BY `sales_agent` ";
$result = mysqli_query($dbc, $query);
if(mysqli_num_rows($result) >= 1)
{
while($row = mysqli_fetch_array($result))
{
$out = $row['sales_agent'];
array_push($names, $out);
}
}
//get the names from the customers table too
$query = "SELECT `customer_name` FROM `customers`
WHERE `customer_name` LIKE '%$customer_name%' ";
$result = mysqli_query($dbc, $query);
if(mysqli_num_rows($result) >= 1)
{
while($row = mysqli_fetch_array($result))
{
$out = $row['customer_name'];
array_push($names, $out);
}
}
echo json_encode($names);
?>