BARRAUX Arthur
3 years ago
15 changed files with 155 additions and 141 deletions
@ -0,0 +1,16 @@ |
|||||
|
<?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); |
||||
|
?> |
@ -1,18 +1,39 @@ |
|||||
<?php |
<?php |
||||
include '../session_restraintes.php'; |
include '../session_restraintes.php'; |
||||
|
?> |
||||
|
|
||||
$bdd = new PDO('mysql:host=localhost;dbname=ticket;charset:utf8', 'root', ''); |
<!DOCTYPE html> |
||||
$reponse = $bdd->query("SELECT DISTINCT * FROM `pannes`"); |
<html lang="fr"> |
||||
$stream = fopen('export/ticket.csv', 'w'); |
<head> |
||||
|
<?php include 'include/menu.html'; ?> |
||||
|
</head> |
||||
|
|
||||
while($line = $reponse->fetch()) { |
<body> |
||||
print_r($line); |
<?php include 'include/nav.php'?> |
||||
echo '<br>'; |
<form id='form' action="cible/export.php" method="post"> |
||||
fputcsv( |
<div class="container-champ"> |
||||
$stream, // file |
<p>Type:</p> |
||||
$line, // arr |
<div class="champ"> |
||||
); |
<select class="entry" name="type"> |
||||
} |
<option value="csv">CSV</option> |
||||
$reponse->closeCursor(); |
<!-- <option value="sql">SQL</option> --> |
||||
fclose($stream); |
</select> |
||||
?> |
</div> |
||||
|
</div> |
||||
|
<div class="container-champ"> |
||||
|
<p>Base:</p> |
||||
|
<div class="champ"> |
||||
|
<select class="entry" name="bdd"> |
||||
|
<option value="pannes">pannes</option> |
||||
|
<option value="logins">logins</option> |
||||
|
</select> |
||||
|
</div> |
||||
|
</div> |
||||
|
<div class="container-champ"> |
||||
|
<div class="submit"> |
||||
|
<input class="entry" type="submit" value="Download"> |
||||
|
</div> |
||||
|
</div> |
||||
|
</form> |
||||
|
</body> |
||||
|
</html> |
||||
|
|
Loading…
Reference in new issue