Files
4WDCSA.co.za/fetch_bar_tabs.php
Local Administrator b83134aca3 Initial commit
2025-04-18 10:32:42 +02:00

35 lines
831 B
PHP

<?php
require_once("session.php");
require_once("connection.php");
require_once("functions.php");
// Prepare the SQL query to fetch bar tabs along with user details, including user_id
$sql = "
SELECT bt.tab_id, u.user_id, u.first_name, u.last_name, u.profile_pic
FROM bar_tabs bt
JOIN users u ON bt.user_id = u.user_id
";
// Execute the query
$result = mysqli_query($conn, $sql);
// Check if there are results
if (mysqli_num_rows($result) > 0) {
// Create an array to hold the data
$barTabs = [];
// Fetch each row
while ($row = mysqli_fetch_assoc($result)) {
$barTabs[] = $row;
}
// Return the data as JSON
echo json_encode($barTabs);
} else {
echo json_encode([]);
}
// Close the database connection
mysqli_close($conn);
?>