<?php include_once 'connect.php'; switch ($_GET["table"]) { case "envoi": readEnvoi($_GET); break; case "personne": readPersonne($_GET); break; case "colis": readColis($_GET); break; default: break; } function readEnvoi($data) { global $conn; $sql = "SELECT * FROM envoi"; $result = $conn->query($sql); //echo $sql; if ($result->num_rows > 0) { // output data of each row echo "<h1>Résultat Table envoi</h1>"; while ($row = $result->fetch_assoc()) { echo " - id personne: " . $row["id_personne"] . " - id colis " . $row["id_colis"] . "<br>"; } } else { echo "0 results"; }
<?php include_once 'connect.php'; switch ($_GET["table"]) { case "personne": readPersonne(); break; case "colis": readColis($_GET); break; default: break; } function readPersonne() { global $DBH; $result = array(); try { $sth = $DBH->prepare("SELECT *,id_personne recid FROM personne"); $sth->execute(); while ($rows = $sth->fetch(PDO::FETCH_ASSOC)) { $result[] = $rows; } echo json_encode($result); } catch (PDOException $e) { echo 'Erreur : ' . $e->getMessage(); } } function readColis($data) { global $DBH;