-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrange.php
134 lines (120 loc) · 4.93 KB
/
range.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1,shrink-to-fit=no">
<!-- Bootstrap CDN -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
<!-- Font Awesome CDN -->
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.8.1/css/all.css">
<!-- Data Tables -->
<link rel="stylesheet" href="https://cdn.datatables.net/1.10.9/css/jquery.dataTables.min.css">
<link rel="stylesheet" href="https://cdn.datatables.net/responsive/1.0.7/css/responsive.dataTables.min.css">
<!-- Modal CSS -->
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" ></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" ></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" ></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.css"/>
</head>
</html>
<?php
// Range.php
if(isset($_POST["From"], $_POST["to"]))
{
$conn = mysqli_connect("localhost", "root", "", "cartsystem","3308");
$result = '';
$query = "SELECT * FROM sales WHERE time BETWEEN '".$_POST["From"]."' AND '".$_POST["to"]."'";
$sql = mysqli_query($conn, $query);
$result .='
<table id="example" class="display responsive nowrap">
<tr>
<th style="background-color: lightblue;">No#</th>
<th style="background-color: lightblue;">Time</th>
<th style="background-color: lightblue;">Original </th>
<th style="background-color: lightblue;">Watermelon </th>
<th style="background-color: lightblue;">Mango </th>
<th style="background-color: lightblue;">Blueberry </th>
<th style="background-color: lightblue;">Apricot </th>
<th style="background-color: lightblue;">Matcha </th>
<th style="background-color: lightblue;">Horlicks </th>
<th style="background-color: lightblue;">Chocolate </th>
<th style="background-color: lightblue;">Taro </th>
<th style="background-color: lightblue;">Roasted </th>
<th style="background-color: lightblue;">Strawberry </th>
<th style="background-color: lightblue;">Action </th>
</tr>';
if(mysqli_num_rows($sql) > 0) {
$i = 1;
while($row = mysqli_fetch_array($sql))
{
$result .='
<tr>
<td>'.$i++.'</td>
<td>'.$row["time"].' </td>
<td>'.$row["original"].'</td>
<td>'.$row["watermelon"].'</td>
<td>'.$row["mango"].'</td>
<td>'.$row["blueberry"].'</td>
<td>'.$row["apricot"].'</td>
<td>'.$row["matcha"].'</td>
<td>'.$row["horlicks"].'</td>
<td>'.$row["chocolate"].'</td>
<td>'.$row["taro"].'</td>
<td>'.$row["roasted"].'</td>
<td>'.$row["strawberry"].'</td>
<td><a href="ownersales.php?id=<?php echo $id;?><#modal2?id=<?php echo $id; ?>"> <button class="btn btn-success btn-sm" style="position:absolute; margin-top: -15px; left:1375px;" data-toggle="modal" data-target="#modal2" name="edit_data"><i class="fas fa-edit"></i></button></a>
<a href="ownersales.php?id=<?php echo $id; ?>"><button class="btn btn-danger btn-sm" style="position:absolute; margin-top: -15px; left:1415px;" name="del_data"><i class="fas fa-trash"></i></button></a></td>
</tr>';
}
}
else
{
$result .='
<tr>
<td style="text-align:center;" colspan="14">No Matching Records Found</td>
</tr>';
}
$result .='</table>';
echo $result;
}
?>
<script src="https://code.jquery.com/jquery-3.4.0.js"></script>
<script type="text/javascript" src="https://cdn.datatables.net/1.10.9/js/jquery.dataTables.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$('#example').DataTable();
} );
</script>
<script>
$(document).ready(function(){
$.datepicker.setDefaults({
dateFormat: 'yy-mm-dd'
});
$(function(){
$("#From").datepicker();
$("#to").datepicker();
});
$('#range').click(function(){
var From = $('#From').val();
var to = $('#to').val();
if(From != '' && to != '')
{
$.ajax({
url:"range.php",
method:"POST",
data:{From:From, to:to},
success:function(data)
{
$('#example').html(data);
}
});
}
else
{
alert("Please Select the Date");
}
});
});
</script>