-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig_generic.php
More file actions
87 lines (82 loc) · 4.16 KB
/
config_generic.php
File metadata and controls
87 lines (82 loc) · 4.16 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
<?php
// config_generic.php
include 'header.php'; // Includes the session check and database connection
include 'sidebar.php';
// --- Search Logic ---
$search_term = isset($_GET['search']) ? trim($_GET['search']) : '';
$sql = "SELECT * FROM config_generic";
if (!empty($search_term)) {
// Prepare the search term for a LIKE query
$search_like = "%" . $search_term . "%";
// Add a WHERE clause to search across relevant text fields
$sql .= " WHERE green_tick LIKE ? OR share_link LIKE ?";
$stmt = $conn->prepare($sql);
$stmt->bind_param("ss", $search_like, $search_like);
$stmt->execute();
$result = $stmt->get_result();
} else {
// If no search term, fetch all results
$result = $conn->query($sql);
}
?>
<!-- Main Content -->
<div class="bg-white p-8 rounded-lg shadow-md w-full">
<div class="flex justify-between items-center mb-6">
<h4 class="text-2xl font-bold text-gray-700">Config Generic Master</h4>
<!-- Search Form -->
<form action="config_generic.php" method="GET" class="flex items-center">
<label for="search" class="mr-2 text-gray-600">Search:</label>
<input type="text" name="search" id="search" value="<?php echo htmlspecialchars($search_term); ?>"
class="shadow-sm border rounded py-2 px-3 text-gray-700 focus:outline-none focus:ring-2 focus:ring-pink-500"
placeholder="Search...">
<button type="submit" class="ml-2 bg-pink-600 hover:bg-pink-700 text-white font-bold py-2 px-4 rounded">
<i class="fas fa-search"></i>
</button>
</form>
</div>
<!-- Data Table -->
<div class="overflow-x-auto">
<table class="min-w-full bg-white">
<thead class="bg-gray-200 text-gray-600 uppercase text-sm leading-normal">
<tr>
<th class="py-3 px-6 text-left">SRNO</th>
<th class="py-3 px-6 text-left">Video</th>
<th class="py-3 px-6 text-left">Image</th>
<th class="py-3 px-6 text-left">Data Sheet</th>
<th class="py-3 px-6 text-left">Certificate</th>
<th class="py-3 px-6 text-left">Green Tick</th>
<th class="py-3 px-6 text-left">Share Link</th>
<th class="py-3 px-6 text-center">Actions</th>
</tr>
</thead>
<tbody class="text-gray-600 text-sm font-light">
<?php
if ($result && $result->num_rows > 0) {
$sr_no = 1;
// output data of each row
while ($row = $result->fetch_assoc()) {
echo "<tr class='border-b border-gray-200 hover:bg-gray-100'>";
echo "<td class='py-3 px-6 text-left whitespace-nowrap'>" . $sr_no++ . "</td>";
echo "<td class='py-3 px-6 text-left'>" . htmlspecialchars($row["video"]) . "</td>";
echo "<td class='py-3 px-6 text-left'>" . htmlspecialchars($row["image"]) . "</td>";
echo "<td class='py-3 px-6 text-left'>" . htmlspecialchars($row["data_sheet"]) . "</td>";
echo "<td class='py-3 px-6 text-left'>" . htmlspecialchars($row["certificate"]) . "</td>";
echo "<td class='py-3 px-6 text-left'>" . htmlspecialchars($row["green_tick"]) . "</td>";
echo "<td class='py-3 px-6 text-left'>" . htmlspecialchars($row["share_link"]) . "</td>";
echo "<td class='py-3 px-6 text-center'>";
echo "<a href='config_generic_edit.php?id=" . $row["id"] . "' class='bg-pink-500 text-white py-1 px-3 rounded text-xs hover:bg-pink-600 flex items-center justify-center'><i class='fas fa-pencil-alt mr-1'></i>Edit</a>";
echo "</td>";
echo "</tr>";
}
} else {
echo "<tr><td colspan='8' class='text-center py-4'>No configurations found.</td></tr>";
}
$conn->close();
?>
</tbody>
</table>
</div>
</div>
<?php
include 'footer.php';
?>