bazdig affiche un vrai rapport sous forme de tableau maintenant
[bazdig.git] / bazdig / sql / exec / index.php
blobe30004575f7f5a8e580661f86084c3cbb759b137
1 <?php
2 session_start();
4 define('WARAQ_ROOT', '../../..');
5 require_once WARAQ_ROOT .'/'. 'ini.php';
7 if (!$_SESSION['db']) {
8 header('Location: '. $bazdig->get('/db')->url );
11 require "code.php";
13 $history_db = new PDO("sqlite:". $bazdig->getparam('db')->file);
14 $work_db = new PDO($_SESSION['db'], $_SESSION['db_user'], $_SESSION['db_password']);
16 SqlCode::set_db($history_db);
17 $query = new SqlCode(stripslashes($_GET['q']));
18 try {
19 $result = $query->exec($work_db);
20 } catch (Exception $e) {
21 die("ERREUR SQL:". $e->getMessage());
24 $query->save();
25 $columns = columnNames($result);
27 <html>
28 <head>
29 <title><?php echo join($columns, ' '); ?></title>
30 <style type="text/css">
31 table tr td {border: solid 1px silver; padding: 10px}
32 table tr th {border: solid 1px grey; padding: 10px}
33 </style>
34 </head>
35 <body>
36 <table>
37 <?php
38 echo "<tr>";
39 foreach ($columns as $c) {
40 echo "<th>$c</th>";
42 echo "</tr>";
43 $rows = $result->fetchAll(PDO::FETCH_NUM);
44 foreach ($rows as $r) {
45 echo "<tr>";
46 foreach ($r as $value) {
47 echo "<td>$value</td>";
49 echo "</tr>";
52 </table>
53 </body>
54 </html>