Added UI and functionality for profiles
This commit is contained in:
13
get_data.php
13
get_data.php
@@ -6,9 +6,16 @@ header('Content-Type: application/json');
|
||||
require_login();
|
||||
|
||||
$user_id = current_user_id();
|
||||
$profile_id = $_SESSION['active_profile_id'] ?? null;
|
||||
|
||||
$stmt = $pdo->prepare("SELECT * FROM projects WHERE user_id = ? ORDER BY sort_order ASC");
|
||||
$stmt->execute([$user_id]);
|
||||
if (!$profile_id) {
|
||||
http_response_code(400);
|
||||
echo json_encode(['success' => false, 'error' => 'No active profile']);
|
||||
exit;
|
||||
}
|
||||
|
||||
$stmt = $pdo->prepare("SELECT * FROM projects WHERE user_id = ? AND profile_id = ? ORDER BY sort_order ASC");
|
||||
$stmt->execute([$user_id, $profile_id]);
|
||||
$projects = $stmt->fetchAll();
|
||||
|
||||
foreach ($projects as &$project) {
|
||||
@@ -23,4 +30,4 @@ foreach ($projects as &$project) {
|
||||
}
|
||||
}
|
||||
|
||||
echo json_encode($projects);
|
||||
echo json_encode($projects);
|
||||
|
||||
Reference in New Issue
Block a user