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 |
|||
include '../session_restraintes.php'; |
|||
?> |
|||
|
|||
$bdd = new PDO('mysql:host=localhost;dbname=ticket;charset:utf8', 'root', ''); |
|||
$reponse = $bdd->query("SELECT DISTINCT * FROM `pannes`"); |
|||
$stream = fopen('export/ticket.csv', 'w'); |
|||
<!DOCTYPE html> |
|||
<html lang="fr"> |
|||
<head> |
|||
<?php include 'include/menu.html'; ?> |
|||
</head> |
|||
|
|||
while($line = $reponse->fetch()) { |
|||
print_r($line); |
|||
echo '<br>'; |
|||
fputcsv( |
|||
$stream, // file |
|||
$line, // arr |
|||
); |
|||
} |
|||
$reponse->closeCursor(); |
|||
fclose($stream); |
|||
?> |
|||
<body> |
|||
<?php include 'include/nav.php'?> |
|||
<form id='form' action="cible/export.php" method="post"> |
|||
<div class="container-champ"> |
|||
<p>Type:</p> |
|||
<div class="champ"> |
|||
<select class="entry" name="type"> |
|||
<option value="csv">CSV</option> |
|||
<!-- <option value="sql">SQL</option> --> |
|||
</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