-
Notifications
You must be signed in to change notification settings - Fork 0
/
dashboard.php
113 lines (102 loc) · 3.2 KB
/
dashboard.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
<?php
require_once("db/db_utils.php");
require_once("utils/constants.php");
$lottery_table_names = "";
foreach(LOTTERIES_INFO as $key => $group_lotteries){
foreach($group_lotteries as $val){
$lottery_table_names .= "<option value='{$val['lottery_name']}'>{$val['lottery_name']}</option>";
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Styled Table with Dropdown</title>
<style>
body {
font-family: Arial, sans-serif;
margin: 20px;
}
table {
width: 100%;
border-collapse: collapse;
}
th, td {
padding: 12px;
border: 1px solid #ddd;
text-align: left;
}
th {
background-color: #f2f2f2;
}
tr:nth-child(even) {
background-color: #f9f9f9;
}
tr:hover {
background-color: #f1f1f1;
}
caption {
caption-side: top;
font-size: 1.5em;
margin: 10px 0;
}
select {
padding: 10px;
margin-bottom: 20px;
}
</style>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
</head>
<body>
<h2>Styled Table with Dropdown Example</h2>
<label for="dataSelect">Choose a Lottery:</label>
<select id="dataSelect" onchange="updateTable()"><?php echo $lottery_table_names; ?></select>
<table>
<caption></caption>
<thead>
<tr>
<th>Draw ID</th>
<th>Lottery Name</th>
<th>Draw Date</th>
<th>Draw Time</th>
<th>Draw Number</th>
<th>Date Count</th>
<th>Date Created</th>
<th>Client</th>
<th>Get Time</th>
</tr>
</thead>
<tbody id="tableBody"></tbody>
</table>
<script>
$(document).ready(function() {
// Initialize table with the first dataset
updateTable();
});
function updateTable() {
let selectElement = document.getElementById('dataSelect');
let selectedElement = selectElement.value;
$.ajax({
url: `utils/entry.php?tbl=` + selectedElement,
type: 'GET',
success: function(response) {
response = JSON.parse(response);
const tableBody = document.getElementById('tableBody');
tableBody.innerHTML = '';
response.data.forEach(row => {
console.log(row);
const tr = document.createElement('tr');
$(tr).append(`<td>${row.drawid}</td><td>${row.lottery_name}</td><td>${row.draw_date}</td><td>${row.draw_time}</td><td>${row.draw_number}</td><td>${row.draw_count}</td><td>${row.date_created}</td><td><a href='${row.client}' target='_blank'>Visit Client Site</a></td><td>${row.get_time}</td>`);
tableBody.appendChild(tr);
});
},
error: function(error) {
console.log('Error: ', error);
}
});
}
</script>
</body>
</html>