-
Notifications
You must be signed in to change notification settings - Fork 0
/
fetch.php
75 lines (57 loc) · 1.27 KB
/
fetch.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
<?php
//fetch.php;
$connect = new PDO("mysql:host=localhost; dbname=testing", "root", "");
if(isset($_POST['query']))
{
$query = "
SELECT DISTINCT customer_email FROM customer_table
WHERE customer_email LIKE '%".trim($_POST["query"])."%'
";
$statement = $connect->prepare($query);
$statement->execute();
$result = $statement->fetchAll();
$output = '';
foreach($result as $row)
{
$output .= '
<li class="list-group-item contsearch">
<a href="javascript:void(0)" class="gsearch" style="color:#333;text-decoration:none;">'.$row["customer_email"].'</a>
</li>
';
}
echo $output;
}
if(isset($_POST['email']))
{
$query = "
SELECT * FROM customer_table
WHERE customer_email = '".trim($_POST["email"])."'
LIMIT 1
";
$statement = $connect->prepare($query);
$statement->execute();
$result = $statement->fetchAll();
$output = '
<table class="table table-bordered table-striped">
<tr>
<th>First Name</th>
<th>Last Name</th>
<th>Email</th>
<th>Gender</th>
</tr>
';
foreach($result as $row)
{
$output .= '
<tr>
<td>'.$row["customer_first_name"].'</td>
<td>'.$row["customer_last_name"].'</td>
<td>'.$row["customer_email"].'</td>
<td>'.$row["customer_gender"].'</td>
</tr>
';
}
$output .= '</table>';
echo $output;
}
?>