Advertisement
Guest User

Untitled

a guest
Jul 28th, 2015
183
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.32 KB | None | 0 0
  1. <?php
  2.  
  3. try {
  4. $handler = new PDO('mysql:host=localhost;dbname=***', '***', '***');
  5. $handler->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  6. } catch(PDOException $e) {
  7. echo $e->getMessage();
  8. die();
  9. }
  10. class guestquestionnaireEntry {
  11. public $id, $date_submitted,
  12. $entry;
  13.  
  14. public function __construct()
  15. {
  16.  
  17. $this->entry = "
  18.  
  19. <table border='1' align='center'>
  20.  
  21. <tr class='tablelist' style='font-size: 8pt;' ><td width='5%' colspan='2'>{$this->ID}</td><td width='40%' colspan='2'><b>Date Received: </b>{$this->date_submitted}</td><td width='45%' colspan='2'>{$this->name}</td><td width='10%'><a href="?ID={$this->ID}">View here</a> </td></tr>
  22.  
  23. </table>
  24.  
  25. ";
  26.  
  27. }
  28.  
  29. }
  30.  
  31. SELECT DATE_FORMAT(date_submitted, '%m/%d/%Y') AS date_submitted FROM guestquestionnaire
  32.  
  33.  
  34. // Checks if the submitted is a number. If so, isolates the ID and adds "where" clause
  35. $id = (!empty($_GET['ID']) && is_numeric($_GET['ID']))? " where ID = '".$_GET['ID']."'" : "";
  36. // Add the $id to the end of the string
  37. // A single call would be SELECT * FROM guestquestionnaire where ID = '1'
  38. $query = $handler->query("SELECT * FROM guestquestionnaire{$id}");
  39. $query->setFetchMode(PDO::FETCH_CLASS, 'guestquestionnaireEntry');
  40.  
  41. while($r = $query->fetch()) {
  42. echo $r->entry, '<br>';
  43. }
  44.  
  45. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement