Пример #1
0
<?php

// get database connection
include_once 'config/database.php';
include_once 'objects/Referentiel.php';
$database = new Database();
$db = $database->getConnection();
// Des données ont-elles été envoyées par POST ?
if ($_GET) {
    //Creates a blank array.
    $row_set = array();
    // Nouvel objet Referentiel
    $referentiel = new Referentiel($db);
    $term = '%' . $_GET['term'] . '%';
    $stmt = $referentiel->readLike($term);
    while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
        //$row['nom']=htmlentities(stripslashes($row['nom']));
        $row_set[] = $row;
        //build an array
        //$row_set[] = $row; //build an array
    }
    // On renvoie le données au format JSON pour le plugin
    echo json_encode($row_set);
}
Пример #2
0
     $bouteille->id_emplacement = $_POST['id_emplacement'];
 }
 if (isset($_POST['commentaire'])) {
     $bouteille->commentaire = $_POST['commentaire'];
 }
 if (isset($_SESSION['id_utilisateur'])) {
     $bouteille->id_utilisateur = $_SESSION['id_utilisateur'];
 }
 // Ajout d'une bouteille
 if ($bouteille->create()) {
     echo "<div class=\"alert alert-success alert-dismissable\">";
     echo "<button type=\"button\" class=\"close\" data-dismiss=\"alert\" aria-hidden=\"true\">&times;</button>";
     echo "La bouteille <strong>" . $_POST['nom'] . "</strong> a été ajoutée :-)";
     echo "</div>";
     // Nouvel objet Referentiel
     $referentiel = new Referentiel($db);
     if ($referentiel->readOne($bouteille->nom) == False) {
         if ($bouteille->id_aoc) {
             // Appellation
             $aoc = new AOC($db);
             $aoc->id = $bouteille->id_aoc;
             $aoc->readName();
             if ($aoc->region) {
                 $referentiel->region = $aoc->region;
             } else {
                 $referentiel->region = '';
             }
         } else {
             $referentiel->region = '';
         }
         // Referentiel
Пример #3
0

<?php 
// page given in URL parameter, default page is one
$page = isset($_GET['page']) ? $_GET['page'] : 1;
// set number of records per page
$records_per_page = 15;
// calculate for the query LIMIT clause
$from_record_num = $records_per_page * $page - $records_per_page;
// include database and object files
include_once 'config/database.php';
include_once 'objects/Referentiel.php';
// instantiate database and product object
$database = new Database();
$db = $database->getConnection();
$vins = new Referentiel($db);
// query products
$stmt = $vins->readAll($page, $from_record_num, $records_per_page);
$num = $stmt->rowCount();
// display the products if there are any
if ($num > 0) {
    echo "<table class='table table-striped table-hover table-responsive'>";
    echo "<tr>";
    echo "<th>Nom</th>";
    echo "<th>Région</th>";
    echo "<th>Type</th>";
    echo "</tr>";
    while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
        extract($row);
        echo "<tr>";
        echo "<td>{$nom}</td>";