Ejemplo n.º 1
0
<?php

include_once 'connect.php';
switch ($_GET["table"]) {
    case "personne":
        getAll();
        break;
    case "colis":
        getColis($_GET);
        break;
    default:
        break;
}
function getAll()
{
    global $conn;
    $list = array();
    $sql = "SELECT * FROM personne";
    $result = $conn->query($sql);
    //echo $sql;
    if ($result->num_rows > 0) {
        // output data of each row
        while ($row = $result->fetch_assoc()) {
            $list[] = $row;
        }
        echo json_encode($list);
    } else {
        echo "0 results";
    }
}
function getColis($data)
Ejemplo n.º 2
0
<?php

include_once 'connect.php';
switch ($_GET["table"]) {
    case "colis":
        getColis($_GET["idPersonne"]);
        break;
    case "personne":
        getPersonne();
        break;
}
function getPersonne()
{
    global $conn;
    $tab_returned = array();
    $sql = "SELECT * FROM personne ";
    //echo $sql;
    $result = $conn->query($sql);
    if ($result->num_rows > 0) {
        while ($row = $result->fetch_assoc()) {
            $tab_returned[] = $row;
        }
        echo json_encode($tab_returned);
        return;
    }
}
function getColis($id)
{
    global $conn;
    $tab_returned = array();
    $sql = "SELECT * FROM colis WHERE id_personne=" . $id;