File "load_from_db.php"
Full Path: /home/analogde/www/Design/Dev tableau/load_from_db.php
File size: 913 bytes
MIME-type: text/x-php
Charset: utf-8
<?php
// Connexion à la base de données
$servername = "analogdepat.mysql.db";
$dbname = "analogdepat";
$username = "analogdepat";
$password = "Un92pac007";
$conn = new mysqli($servername, $username, $password, $dbname);
if ($conn->connect_error)
{
die("Connection failed: " . $conn->connect_error);
}
echo "OK";
// Requête pour récupérer la dernière ligne ajoutée à la table
//$sql = "SELECT * FROM tableau_json ORDER BY id DESC LIMIT 1";
//echo $sql;
//$result = $conn->query($sql);
$sql = "SELECT data FROM tableau_json ORDER BY id DESC LIMIT 1";
$result = $conn->query($sql);
$tableData = [];
if ($result->num_rows > 0) {
while($row = $result->fetch_assoc()) {
$tableData[] = $row;
}
}
$conn->close();
// Retourner les données au format JSON
header('Content-Type: application/json');
echo json_encode($tableData);
?>