-
Notifications
You must be signed in to change notification settings - Fork 0
/
create_listing.php
242 lines (183 loc) · 6.11 KB
/
create_listing.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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
<?php
include_once 'db_connect.php';
$c="select * from currency";
$result=mysqli_query($db,$c);
$currency=mysqli_fetch_assoc($result);
$ref_price=$currency['ref_price'];
$key_ref=$currency['key_ref'];
?>
<html>
<head>
<title>load more</title>
<style>
input {
resize: horizontal;
width: 200px;
}
input:active {
width: auto;
}
input:focus {
min-width: 200px;
}
input,
select,
textarea {
color: black;
}
</style>
<script src="http://code.jquery.com/jquery-3.3.1.min.js"></script>
<script>
$(document).ready(function() {
$('.loader').bind('ajaxStart', function() {
$(this).show();
}).bind('ajaxStop', function() {
$(this).hide();
});
$(function() {
$('.sub').click(function(e) {
e.preventDefault();
var item_name = $(this).parent().find('.item_name').val();
var price = $(this).parent().find('.price').val();
var sellprice = $(this).parent().find('.sellprice').val();
console.log(item_name);
$.ajax({
type: 'POST',
url: 'update_price.php',
data: {
item_name: item_name,
price: price,
sellprice: sellprice
},
success: function(data) {
$('.status').html(data);
}
});
});
return false;
});
$(function() {
$("#search").keyup(function(e) {
e.preventDefault();
var value = $("#search").val();
$.ajax({
type: 'GET',
url: 'create_listing.php',
data: 's=' + value,
success: function(data) {
$('.list-item').html(data);
}
});
});
return false;
});
});
</script>
</head>
<body>
<div style="position:fixed; text-align:center;width:100%; z-index:999;background-color:lightgrey;top:0px; color:black;">
<form method="get">
Filter : <input type="text" id="search">
</form>
<p class="status" style="color:green">
Status here : Current Refine price:
<?php echo $ref_price;?>$ || 1 key =
<?php echo $key_ref;?> ref
</p>
<div class="loader" style="display:none">
<img src="loader.gif">
</div>
</div>
<div class="list-item" style="padding-top:5em">
<?php
if(isset($_GET['s'])){ // filter as value entered in input text field
$value=$_GET['s']; //filtering `s` is name of form input element
$q="select * from imported where item_name like '%".$value."%'";
$res=mysqli_query($db,$q);
while($row=mysqli_fetch_array($res)){
//fetch sell price from sell table
$query="select price from sell where item_name='".$row['item_name']."'";
$sell=mysqli_query($db,$query);
$sellprice=mysqli_fetch_array($sell);
//checking whether buyprice 'price' < 'sellprice'
$ex=explode('.', $row['price']);
$ex2=explode('.', $sellprice['price']);
$buy_price=($ex[0]*.11+$ex[1]*.33+$ex[2]+$ex[3]*$key_ref);
$sell_price=($ex2[0]*.11+$ex2[1]*.33+$ex2[2]+$ex2[3]*$key_ref);
if($sell_price <= $buy_price ){
$bgcolor='red';
}
else if(strpos($row['item_name'],'Unusual') !== false){
$bgcolor='#8650AC';
$bordercolor='#3C352E';
}
else if(strpos($row['item_name'],'Strange') !== false){
$bgcolor='#CF6A32';
}
else{
$bgcolor='white';
}
?>
<div style="position:relative;float:left; padding: 20px;margin:5px;border:1px solid black; width:270px;height:270px;background-color:<?php echo $bgcolor?>;">
<?php echo $row['id'];?><img src="<?php echo $row['item_img']; ?>"><br>
<p>
<?php echo $row['item_name'];?><br>
</p>
<form method="post">
Name: <input type="text" value="<?php echo $row['item_name'];?>" class="item_name" name="item_name" readonly>
<br> Buy :<input type="text" value="<?php echo $row['price'];?>" class="price" name="price">
<br> Sell :<input type="text" value="<?php echo $sellprice['price'];?>" class="sellprice" name="sellprice"><br>
<a href="<?php echo $row['item_link']; ?>" target="_blank">
Scm: <?php echo $row['sale_price'];?> </a>
<br><input type="submit" class="sub" value="update">
</form>
</div>
<?php } } else {
$q="select * from imported";
$res=mysqli_query($db,$q);
if(mysqli_num_rows($res)>0){
while($row=mysqli_fetch_array($res)){
//fetching item sellprice from `sell` table
$query="select price from sell where item_name='".$row['item_name']."'";
$sell=mysqli_query($db,$query);
$sellprice=mysqli_fetch_array($sell);
//checking whether buyprice 'price' < 'sellprice'
$ex=explode('.', $row['price']);
$ex2=explode('.', $sellprice['price']);
$buy_price=($ex[0]*.11+$ex[1]*.33+$ex[2]+$ex[3]*$key_ref);
$sell_price=($ex2[0]*.11+$ex2[1]*.33+$ex2[2]+$ex2[3]*$key_ref);
if($sell_price <= $buy_price ){
$bgcolor='red';
}
else if(strpos($row['item_name'],'Unusual') !== false){
$bgcolor='#8650AC';
$bordercolor='#3C352E';
}
else if(strpos($row['item_name'],'Strange') !== false){
$bgcolor='#CF6A32';
}
else{
$bgcolor='white';
}
?>
<form method="post">
<div style="position:relative;float:left; padding: 20px;margin:5px;border:1px solid black; width:270px;height:270px;background-color:<?php echo $bgcolor?>;">
<?php echo $row['id'];?><img src="<?php echo $row['item_img']; ?>"><br>
<p>
<?php echo $row['item_name'];?>
</p>
Name: <input type="text" value="<?php echo $row['item_name'];?>" class="item_name" name="item_name" readonly>
<br> Buy : <input type="text" value="<?php echo $row['price'];?>" class="price" name="price">
<br> Sell: <input type="text" value="<?php echo $sellprice['price'];?>" class="sellprice" name="sellprice">
<br>
<a href="<?php echo $row['item_link']; ?>" target="_blank">
Scm: <?php echo $row['sale_price'];?> </a>
<br>
<input type="submit" value="Update" class="sub">
</div>
<?php }?>
</form>
<?php } }?>
</div>
</body>
</html>