CVsys/fetch_block.php
2025-06-09 14:03:07 +08:00

29 lines
673 B
PHP

<?php
include 'connectDB.php';
$cvId = $_GET['cvId'];
$tableName = $_GET['tableName'];
if ($tableName == 'profile'){
// visible: 0-private; 1-public; 2-authentication
$sql = "SELECT * FROM `profile` WHERE cid = $cvId AND (visible = 1 OR visible = 2)";
}
else{
$sql = "SELECT * FROM `$tableName` WHERE owner = $cvId and visible = 1 GROUP BY (sequence)";
}
$result = $conn->query($sql);
$tableData = [];
if ($result->num_rows > 0) {
// Loop through each row of the result set
while ($row = $result->fetch_assoc()) {
// Add each row to the $tableData array
$tableData[] = $row;
}
}
echo json_encode($tableData);
$conn->close();
?>