-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuser.php
More file actions
280 lines (195 loc) · 7.37 KB
/
user.php
File metadata and controls
280 lines (195 loc) · 7.37 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
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
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
<?php
include "connection.php";
?>
<!DOCKTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!--<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">-->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
</head>
<body style="background-color: #00ffbf">
<!-- The insert Modal -->
<div class="modal fade" id="myModal">
<div class="modal-dialog modal-sm">
<div class="modal-content">
<!-- Modal Header -->
<div class="modal-header">
<h3>MY Pesticides</h3>
<button type="button" class="close" data-dismiss="modal">×</button>
</div>
<form action="inserting.php" method="POST">
<div class="modal-body">
<div class="form-group">
<label for="pestname">Enter pesticide name: </label>
<input type="text" name="pname" id="pestname">
</div>
<div class="form-group">
<label for="cropname">Applied on: </label>
<br>
<input type="text" name="cname" id="cropname">
</div>
<div class="form-group">
<label for="company">Product company:</label>
<input type="text" name="comp" id="company">
</div>
</div>
<!-- Modal footer -->
<div class="modal-footer">
<button type="submit" name="insertdata" class="btn btn-dark">Submit</button>
</div>
</form>
</div>
</div>
</div>
<!-- ########################################################################################################-->
<!-- The edit Modal -->
<div class="modal fade" id="editmodal">
<div class="modal-dialog modal-sm">
<div class="modal-content">
<!-- Modal Header -->
<div class="modal-header">
<h3>Edit Pesticides</h3>
<button type="button" class="close" data-dismiss="modal">×</button>
</div>
<form action="updatedata.php" method="POST">
<div class="modal-body">
<div class="form-group">
<label>Pesticide name: </label>
<input type="text" name="pname" id="pestid">
</div>
<div class="form-group">
<label>Crops: </label>
<br>
<input type="text" name="cname" id="cropid">
</div>
<div class="form-group">
<label >Product company:</label>
<input type="text" name="comp" id="compid">
</div>
</div>
<!-- Modal footer -->
<div class="modal-footer">
<button type="submit" name="updatedata" class="btn btn-secondary">Save Changes</button>
</div>
</form>
</div>
</div>
</div>
<!--############################################################################################################-->
<!-- ########################################################################################################-->
<!-- The delete Modal -->
<div class="modal fade" id="deletemodal">
<div class="modal-dialog modal-sm">
<div class="modal-content">
<!-- Modal Header -->
<div class="modal-header">
<h3>Delete Pesticides</h3>
<button type="button" class="close" data-dismiss="modal">×</button>
</div>
<form action="deleteuser.php" method="POST">
<div class="modal-body">
<h4>Do you want to delete this data???</h4>
<div class="form-group">
<input type="hidden" name="pname" id="pestusn">
</div>
<div class="form-group">
<br>
<input type="hidden" name="cname" id="cropusn">
</div>
<div class="form-group">
<input type="hidden" name="comp" id="compusn">
</div>
</div>
<!-- Modal footer -->
<div class="modal-footer">
<button type="button" name="updatedata" class="btn btn-secondary" data-dismiss="modal">No</button>
<button type="submit" name="deletedata" class="btn btn-primary" >Yes</button>
</div>
</form>
</div>
</div>
</div>
<div style="background-color: #ffcc66;">
<h2 style="font-family: times new roman;text-align: center;">Used Pesticides</h2>
<!-- Button to Open the Modal -->
<button type="button" class="btn btn-dark glyphicon glyphicon-plus" data-toggle="modal" data-target="#myModal" style="margin-left: 1100px; margin-bottom: 10px;"><span class="glyphicon glyphicon-plus"></span>
New
</button>
</div>
<?php
$b="Update";
$m="Delete";
echo "<table class=\"table table-striped\">
<thead>
<tr>
<th>Pesticide name</th>
<th>Crops</th>
<th>Company name </th>
<th>Date</th>
<th>Update</th>
<th>Delete</th>
</tr>
</thead>";
echo "<tbody>";
$sql1="SELECT * FROM my_pest";
$result1=mysqli_query($con,$sql1);
$check=mysqli_num_rows($result1);
if($check>0)
{
while($c=mysqli_fetch_array($result1))
{
echo "<tr>";
echo "<td>".$c['pestname']."</td>";
echo "<td>".$c['crops']."</td>";
echo "<td>".$c['company']."</td>";
echo "<td>".$c['boughtdate']."</td>";
#echo "<td>"."<input type=\"submit\" value=\"Edit\" class=\"editbtn\">"."</td>";
echo "<td>"."<button type=\"button\" class=\"btn btn-primary editbtn\">".$b."</button>"."</td>";
echo "<td>"."<button type=\"button\" class=\"btn btn-danger deletebtn\">".$m."</button>"."</td>";
echo "</tr>";
}
}
echo "</tbody>";
echo "</tabel>";
?>
<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>
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
<script>
$(document).ready(function(){
$('.deletebtn').on('click',function(){
$('#deletemodal').modal('show');
$tr=$(this).closest('tr');
var data=$tr.children("td").map(function(){
return $(this).text();
}).get();
console.log(data);
$('#pestusn').val(data[0]);
$('#cropusn').val(data[1]);
$('#compusn').val(data[2]);
});
});
</script>
<script>
$(document).ready(function(){
$('.editbtn').on('click',function(){
$('#editmodal').modal('show');
$tr=$(this).closest('tr');
var data=$tr.children("td").map(function(){
return $(this).text();
}).get();
console.log(data);
$('#pestid').val(data[0]);
$('#cropid').val(data[1]);
$('#compid').val(data[2]);
});
});
</script>
</body>
</html>