-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsearch.php
More file actions
113 lines (104 loc) · 3.63 KB
/
search.php
File metadata and controls
113 lines (104 loc) · 3.63 KB
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
<?php
session_start();
include("connection.php");
include("functions.php");
$user_data = check_login($con);
?>
<!DOCTYPE html>
<html>
<head>
<title>My database project</title>
<link rel="stylesheet" href="tabs.css">
</head>
<body>
<!-- input: Order_ID
output: buyer | state | products | cost | amount | seller | time -->
<div style = "padding: 16px; background-color: #FAEBD7;">
<h3>Search by ID</h3>
<form method="post">
<input id="text" type="text" name="search_id" placeholder="Enter the order ID">
<input id="button" type="submit" name="Search" value="Search"><br>
</form>
</div>
<div style = "padding: 15px;" >
<?php
if( $_SERVER['REQUEST_METHOD'] == "POST" && isset($_POST['Search']) ) {
$search_id = $_POST['search_id'];
// seller --> buyer
// $seller = search_seller($search_id);
$query = "select id from sell where order_id = '$search_id' limit 1";
$result = mysqli_query($con, $query);
$seller = mysqli_fetch_assoc($result);
$seller = $seller['id'];
$query = "select user_name from person where id = '$seller';";
$result = mysqli_query($con, $query);
$seller = mysqli_fetch_assoc($result);
$seller = $seller['user_name'];
// $buyer = search_buyer($search_id);
$query = "select id from buy where order_id = '$search_id' limit 1";
$result = mysqli_query($con, $query);
$buyer = mysqli_fetch_assoc($result);
$buyer = $buyer['id'];
$query = "select user_name from person where id = '$buyer';";
$result = mysqli_query($con, $query);
$buyer = mysqli_fetch_assoc($result);
$buyer = $buyer['user_name'];
echo '<h4>' . $buyer . ' --> ' . $seller . '</h4>';
// table
echo '<table style = "border: 1px solid;" >';
echo '<tr>';
echo '<th style = "border: 1px solid;" >Item</th>';
echo '<th style = "border: 1px solid;" >Amount</th>';
echo '<th style = "border: 1px solid;" >cost</th>';
echo '</tr>';
//
$query = "select count(*) as cnt from contain where order_id = '$search_id';";
$result = mysqli_query($con, $query);
$data = mysqli_fetch_assoc($result);
$len = $data['cnt'];
//echo $len;
//
$query = "select product_id from contain where order_id = '$search_id';";
$result_r = mysqli_query($con, $query);
while($row = mysqli_fetch_row($result_r)) {
$p_id = $row[0];
$query = "select * from product where product_id = '$p_id';";
$result = mysqli_query($con, $query);
$product = mysqli_fetch_assoc($result);
echo '<tr>';
echo '<td style = "border: 1px solid;" >' . $product['p_name'] . '</th>';
echo '<td style = "border: 1px solid;" >' . $product['cost'] . '</th>';
echo '<td style = "border: 1px solid;" >';
$query = "select * from contain where product_id = '$p_id';";
$result = mysqli_query($con, $query);
$amount = mysqli_fetch_assoc($result);
$amount = $amount['amount'];
echo $amount;
echo '</th>';
echo '</tr>';
}
echo '</table><br><br>';
// state
$cnt = 0;
echo '<p style = "font_size: 8px; color: green;"> preapring ---> ';
$query = "select count(*) as state from states where order_id = '$search_id';";
$result = mysqli_query($con, $query);
$cnt = mysqli_fetch_assoc($result);
$cnt = $cnt['state'];
if($cnt >= 1) {
echo '<a style = "font_size: 8px; color: green;"> sending ---> </a>';
}
else {
echo '<a style = "font_size: 8px; color: black;"> sending ---> </a>';
}
if($cnt >= 2) {
echo '<a style = "font_size: 8px; color: green;"> arrived </a>';
}
else {
echo '<a style = "font_size: 8px; color: black;"> arrived </a>';
}
echo '</p>';
}
?>
</div>
</body>