Facebook
From php, 1 Week ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 27
  1. <?php
  2.  
  3. // Query schrijven
  4. $query = "SELECT * FROM  joke";
  5.  
  6. try
  7. {
  8.     $pdo = new PDO("odbc:odbc2sqlserver");
  9. }
  10. catch(PDOException $e)
  11. {
  12.     echo "<h1>Fout</h1>";
  13.     echo "<p>" . $error->getMessage() . "</p>";
  14. };
  15.  
  16. // Query gaan uitvoeren
  17. try{
  18.     $result = $pdo->query($query);
  19. }
  20. catch(PDOException $error)
  21. {
  22.     echo "<p>Error: " . $error->getMessage() . "</p>";
  23. };
  24.  
  25. // Weergeven van het resultaat van de query
  26. while($row = $result->fetch(PDO::FETCH_ASSOC))
  27.     echo "<p>" . $row["joketext"] . "</p>";
  28.  
  29. ?>