-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsearch2.php
More file actions
88 lines (65 loc) · 2.17 KB
/
search2.php
File metadata and controls
88 lines (65 loc) · 2.17 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
<?php
include('connection.php');
?>
<!DOCKTYPE HTML>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"></script>
</head>
<body>
<form action="" method="POST">
<input type="text" placeholder="Enter crop name" name="crop">
<input type="submit" name="boton" value="Search" class="btn btn-dark" style="margin-left:50px;">
</form>
<?php
if(isset($_POST['boton']))
{
$crop=$_POST['crop'];
$sql="select product_name,quantity,company,price from product_detail pd,pesticide_usage pu where pd.product_id=pu.product_id and pu.crops like '%$crop%';";
$temp=mysqli_query($con,$sql);
$check=mysqli_num_rows($temp);
if($check>0)
{
$sql1="select product_name,quantity,company,price from product_detail pd,pesticide_usage pu where pd.product_id=pu.product_id and pu.crops like '%$crop%' union select product_name,quantity,company,price from product_detail pd,pesticide_usage pu where pd.product_id=pu.product_id and pu.crops like '%any_crops%';";
$temp2=mysqli_query($con,$sql1);
echo "<div style=\" margin-left:0px; \">";
echo "<table class=\"table table-striped\">
<thead class=\"thead-dark\">
<tr>
<th >Product Name</th>
<th>Quantity</th>
<th>Company</th>
<th >Price</th>
</thead>
</tr>";
}
else
{
echo '<script> alert("data not found");</script>';
exit();
}
$check1=mysqli_num_rows($temp2);
if($check1>0)
{
while($b=mysqli_fetch_array($temp2))
{
//echo "<tr><td>".$a['product_name']."</tr><td>".$a['quantity']."</tr><td>".$a['company']."</tr><td>".$a['price']."</td></tr>";
//echo $a['product_name'] ;
echo "<tr>";
echo "<td>".$b['product_name']."</td>";
echo "<td>".$b['quantity']."</td>";
echo "<td>".$b['company']."</td>";
echo "<td>".$b['price']."</td>";
echo "</tr>";
}
echo "</table>";
}
echo "</div>";
}
?>
</body>
</html>