Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- try {
- $handler = new PDO('mysql:host=localhost;dbname=***', '***', '***');
- $handler->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
- } catch(PDOException $e) {
- echo $e->getMessage();
- die();
- }
- class guestquestionnaireEntry {
- public $id, $date_submitted,
- $entry;
- public function __construct()
- {
- $this->entry = "
- <table border='1' align='center'>
- <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>
- </table>
- ";
- }
- }
- SELECT DATE_FORMAT(date_submitted, '%m/%d/%Y') AS date_submitted FROM guestquestionnaire
- // Checks if the submitted is a number. If so, isolates the ID and adds "where" clause
- $id = (!empty($_GET['ID']) && is_numeric($_GET['ID']))? " where ID = '".$_GET['ID']."'" : "";
- // Add the $id to the end of the string
- // A single call would be SELECT * FROM guestquestionnaire where ID = '1'
- $query = $handler->query("SELECT * FROM guestquestionnaire{$id}");
- $query->setFetchMode(PDO::FETCH_CLASS, 'guestquestionnaireEntry');
- while($r = $query->fetch()) {
- echo $r->entry, '<br>';
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement