Browse Source

avancée

master
BARRAUX Arthur 3 years ago
parent
commit
94e4bd0112
  1. 22
      referant/cible/export.php
  2. 8
      referant/cible/search.php

22
referant/cible/export.php

@ -1,24 +1,10 @@
<?php <?php
// $connect = mysqli_connect("localhost", "root", "", "ticket");
// $query = "SELECT * FROM `" .$_POST['bdd'] ."`";
// $title = array_keys(mysqli_fetch_assoc(mysqli_query($connect, $query)));
//
// header('Content-Type: text/csv; charset=utf-8');
// header('Content-Disposition: attachment; filename=' .$_POST['bdd'] .'.csv');
// $output = fopen("php://output", "w");
// fputcsv($output, $title);
// $result = mysqli_query($connect, $query);
// while($row = mysqli_fetch_assoc($result)) {
// fputcsv($output, $row);
// }
// fclose($output);
//
$bdd = new SQLite3('../../database/ticket_panne.db', SQLITE3_OPEN_READWRITE); $bdd = new SQLite3('../../database/ticket_panne.db', SQLITE3_OPEN_READWRITE);
$stmt = $bdd->prepare("SELECT * FROM :base"); $stmt = $bdd->prepare('SELECT * FROM :base');
$stmt->bindValue(':base', $_POST['bdd']); $stmt->bindParam(':base', $_POST['bdd']);
$title = array_keys($stmt->fetchArray(SQLITE3_ASSOC)); $res = $stmt->execute();
$title = array_keys($res->fetchArray(SQLITE3_ASSOC));
header('Content-Type: text/csv; charset=utf-8'); header('Content-Type: text/csv; charset=utf-8');
header('Content-Disposition: attachment; filename=' .$_POST['bdd'] .'.csv'); header('Content-Disposition: attachment; filename=' .$_POST['bdd'] .'.csv');

8
referant/cible/search.php

@ -3,10 +3,12 @@ $bdd = new SQLite3('../../database/ticket_panne.db', SQLITE3_OPEN_READWRITE);
try { try {
// $reponse = $bdd->query("SELECT * FROM pannes WHERE `" .$_POST['champ'] ."`='" .$_POST['value'] ."'"); // $reponse = $bdd->query("SELECT * FROM pannes WHERE `" .$_POST['champ'] ."`='" .$_POST['value'] ."'");
$reponse = $bdd->prepare("SELECT * FROM pannes WHERE `" .$_POST['champ'] ."`='" .$_POST['value'] ."'"); $reponse = $bdd->prepare("SELECT * FROM pannes WHERE :champ=:value");
$reponse->execute(); $reponse->bindParam(':champ', $_POST['champ']);
$reponse->bindValue(':value', $_POST['value']);
$fetch = $reponse->execute();
$result = []; $result = [];
while ($line = $reponse->fetchArray()) { while ($line = $fetch->fetchArray()) {
array_push($result, $line); array_push($result, $line);
}; };

Loading…
Cancel
Save