File "get_json_from_db.php"
Full Path: /home/analogde/www/New folder/get_json_from_db.php
File size: 882 bytes
MIME-type: text/x-php
Charset: utf-8
<?php
$host = "analogdepat.mysql.db";
$dbname = "analogdepat";
$username = "analogdepat";
$password = "Un92pac007";
$conn = new mysqli($host, $username, $password, $dbname);
// Vérification de la connexion
if ($conn->connect_error) {
die("Erreur de connexion : " . $conn->connect_error);
}
if (isset($_GET['id'])) {
$id = $_GET['id'];
$sql = "SELECT column_name FROM table_DB_planning WHERE id = ?";
$stmt = $conn->prepare($sql);
$stmt->bind_param("i", $id);
$stmt->execute();
$result = $stmt->get_result();
if ($result->num_rows > 0) {
$row = $result->fetch_assoc();
echo json_encode($row);
} else {
echo json_encode(["error" => "Aucun enregistrement trouvé."]);
}
$stmt->close();
} else {
echo json_encode(["error" => "Paramètre manquant."]);
}
$conn->close();
?>