Advertisement
Guest User

Untitled

a guest
Jun 21st, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.47 KB | None | 0 0
  1.  <html>
  2.   <head>
  3.  
  4.  </head>
  5.  <body>
  6.  </html>
  7.  <?php
  8.  if (isset($_POST['Code_postal'])){$Code_postal=$_POST['Code_postal'] ;}
  9. if (isset($_POST['Gouvernorat'])){$Gouvernorat=$_POST['Gouvernorat'] ;}
  10. if (isset($_POST[' delegation '])){$délégation=$_POST[' delegation '];}
  11. echo "<table style='border: solid 1px black;'>";
  12. echo "<tr><th>activit</th><th>Address</th><th>Localit</th><th>delegation</th></th><th>Gouvernorat</th></tr>";
  13.  
  14.  
  15. class TableRows extends RecursiveIteratorIterator {
  16.     function __construct($it) {
  17.         parent::__construct($it, self::LEAVES_ONLY);
  18.     }
  19.  
  20.     function current() {
  21.         return "<td style='width:200px;border:1px solid black;'>" . parent::current(). "</td>";
  22.     }
  23.  
  24.     function beginChildren() {
  25.         echo "<tr>";
  26.     }
  27.  
  28.     function endChildren() {
  29.         echo "</tr>" . "\n";
  30.     }
  31. }
  32.  
  33. $DBSERVER='localhost';
  34. $DBUSER='user';
  35. $DBPASS='user';
  36. $DBNAME='viamobile1';
  37.  
  38.  
  39.  
  40. try {
  41.     $conn = new PDO("mysql:host=$DBSERVER;dbname=$DBNAME", $DBUSER, $DBPASS);
  42.     $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  43.     $stmt = $conn->prepare("SELECT * FROM viamobile");
  44.     $stmt->execute();
  45.  
  46.     // set the resulting array to associative
  47.     $result = $stmt->setFetchMode(PDO::FETCH_ASSOC);
  48.     foreach(new TableRows(new RecursiveArrayIterator($stmt->fetchAll())) as $k=>$v) {
  49.         echo $v;
  50.     }
  51. }
  52. catch(PDOException $e) {
  53.     echo "Error: " . $e->getMessage();
  54. }
  55. $conn = null;
  56. echo "</table>";
  57. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement