-
Notifications
You must be signed in to change notification settings - Fork 1
/
get_current_block_count.php
36 lines (27 loc) · 1008 Bytes
/
get_current_block_count.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
<?php
header('Content-Type: application/json');
// Include database configuration
include 'config_1.php';
// Create a new database connection
$conn = getDbConnection();
// Function to fetch total blocks count and current block count
function fetchBlockCounts($conn) {
// Query to get the maximum ID (considered as the total number of blocks)
$maxIdResult = $conn->query("SELECT MAX(id) AS maxId FROM blocks");
$maxIdRow = $maxIdResult->fetch_assoc();
// Get the maximum ID, which represents the total number of blocks
$totalBlocks = (int)$maxIdRow['maxId']; // Cast to integer for safety
// Set current block count to be the same as total blocks in this context
$currentBlockCount = $totalBlocks;
return [
'totalBlocks' => $totalBlocks,
'currentBlockCount' => $currentBlockCount
];
}
// Fetch block counts
$blockCounts = fetchBlockCounts($conn);
// Close connection
$conn->close();
// Return the data as JSON
echo json_encode($blockCounts);
?>