Exemple #1
0
<?php

include_once 'connect.php';
switch ($_GET["table"]) {
    case "scores":
        readScore($_GET);
        break;
    case "personnes":
        readPersonne($_GET);
        break;
    case "documents":
        readDocument($_GET);
        break;
    default:
        break;
}
function readScore($data)
{
    global $conn;
    $sql = "SELECT * FROM scores";
    $result = $conn->query($sql);
    //echo $sql;
    $lists = array();
    if ($result->num_rows > 0) {
        // output data of each row
        while ($row = $result->fetch_assoc()) {
            $lists[] = $row;
        }
        echo json_encode($lists);
    } else {
        echo "0 results";
Exemple #2
0
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
  <script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
<?php 
include_once '../php/connect.php';
readScore();
readPersonne();
readDocument();
function readScore()
{
    global $conn;
    $sql = "SELECT * FROM scores";
    $result = $conn->query($sql);
    //echo $sql;
    if ($result->num_rows > 0) {
        // output data of each row
        echo "<h1 style='text-align:center;'>Table score</h1>";
        echo "<table class='table table-hover'>\n\t\t\t\t <thead>\n      \t\t\t\t\t<tr class='danger'>\n\t\t\t\t\t        <th>Id Score</th>\n\t\t\t\t\t        <th>Id Personne</th>\n\t\t\t\t\t        <th>Id Document</th>\n\t\t\t\t\t        <th>Distance</th>\n\t\t\t\t\t        <th>Mise à jour</th>\n     \t\t\t\t\t </tr>\n   \t\t\t\t </thead><tbody> ";
        while ($row = $result->fetch_assoc()) {
            echo "<tr class='info'><td>" . $row["id_scores"] . "</td><td> " . $row["id_perso"] . "</td><td> " . $row["id_doc"] . "</td><td> " . $row["distance"] . " </td><td> " . $row["maj"] . "</td></tr>";
        }
        echo "</tbody>\n  </table>";
    } else {
        echo "Table score vide<br>";
    }
}
function readPersonne()
{
    global $conn;
    $sql = "SELECT * FROM personnes";