-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProduct_Display.php
121 lines (105 loc) · 2.62 KB
/
Product_Display.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
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
114
115
116
117
118
119
120
121
<?php
session_start();
include('connect.php');
?>
<!DOCTYPE html>
<html>
<head>
<title>Product Display</title>
</head>
<body>
<form action="Product_Display.php" method="post">
<fieldset>
<legend>Product List :</legend>
<table width="100%">
<tr>
<td align="right">
<input type="text" name="txtData" placeholder="Enter Search Data" />
<input type="submit" name="btnSearch" value="Search" />
</td>
</tr>
</table>
<hr/>
<table>
<?php
if(isset($_POST['btnSearch']))
{
$txtData=$_POST['txtData'];
$query1="SELECT * FROM product WHERE ProductName LIKE '%$txtData%' OR Price='$txtData' ";
$result1=mysqli_query($connection,$query1);
$count1=mysqli_num_rows($result1);
for($i=0;$i<$count1;$i+=4)
{
$query2="SELECT * FROM product
WHERE ProductName LIKE '%$txtData%'
OR Price='$txtData'
LIMIT $i,4";
$result2=mysqli_query($connection,$query2);
$count2=mysqli_num_rows($result2);
echo "<tr>";
for($x=0;$x<$count2;$x++)
{
$row=mysqli_fetch_array($result1);
$ProductID=$row['ProductID'];
$ProductName=$row['ProductName'];
$Price=$row['Price'];
$ProductImage1=$row['ProductImage1'];
list($width,$height)=getimagesize($ProductImage1);
$w=$width/2;
$h=$height/2;
?>
<td>
<img src="<?php echo $ProductImage1 ?>" width="<?php echo $w ?>" height="<?php echo $h ?>">
<hr/>
<b><p><?php echo $ProductName ?></p></b>
<b><p><?php echo $Price ?> USD</p></b>
<hr/>
<a href="Product_Details.php?ProductID=<?php echo $ProductID ?>">Details</a>
</td>
<?php
}
echo "</tr>";
}
}
else
{
$query1="SELECT * FROM product";
$result1=mysqli_query($connection,$query1);
$count1=mysqli_num_rows($result1);
for($i=0;$i<$count1;$i+=4)
{
$query2="SELECT * FROM product
LIMIT $i,4";
$result2=mysqli_query($connection,$query2);
$count2=mysqli_num_rows($result2);
echo "<tr>";
for($x=0;$x<$count2;$x++)
{
$row=mysqli_fetch_array($result1);
$ProductID=$row['ProductID'];
$ProductName=$row['ProductName'];
$Price=$row['Price'];
$ProductImage1=$row['ProductImage1'];
list($width,$height)=getimagesize($ProductImage1);
$w=$width/2;
$h=$height/2;
?>
<td>
<img src="<?php echo $ProductImage1 ?>" width="<?php echo $w ?>" height="<?php echo $h ?>">
<hr/>
<b><p><?php echo $ProductName ?></p></b>
<b><p><?php echo $Price ?> USD</p></b>
<hr/>
<a href="Product_Details.php?ProductID=<?php echo $ProductID ?>">Details</a>
</td>
<?php
}
echo "</tr>";
}
}
?>
</table>
</fieldset>
</form>
</body>
</html>