public static function read($id) { global $db; if ($db) { $q = $db->prepare('SELECT * FROM recording WHERE id = ?'); $q->execute(array($id)); if ($item = $q->fetch()) { $recording = new Recording($item['title'], $item['version'], $item['language'], $item['narration_type'], $item['running_time'], $item['zip_file_size'], $item['catalog_date'], $item['website_link']); $recording->setID($item['id']); return $item; } } return false; }
Enter the catalog date of the recording (yyyy-mm-dd): <input type="text" name="catalog_date"></input><br/> Enter the website link of the recording: <input type="text" name="website_link"></input><br/> <input type="submit" name="submit" value="submit"></input><br/> </form> <?php if (isset($audiobook)) { ?> <p>The last recording entered was "<?php echo $audiobook->getTitle(); ?> ". It was given ID number <?php echo $audiobook->getID(); ?> in the database.</p> <?php } else { ?> <p>The following LibriVox recordings are currently in the database: "<?php echo $audiobook = Recording::recording_list(); ?> ". </p> <?php } ?> </body> </html>
<?php require_once 'config.php'; require_once 'recording.php'; if (isset($_POST['create'])) { $created = new Recording($_POST['title'], $_POST['version'], $_POST['language'], $_POST['narration_type'], $_POST['running_time'], $_POST['zip_file_size'], $_POST['catalog_date'], $_POST['website_link']); $created->create(); } elseif (isset($_POST['delete'])) { $deleted = new Recording($_POST['id']); $deleted->delete(); } elseif (isset($_POST['update'])) { $updated = new Recording($_POST['title'], $_POST['version'], $_POST['language'], $_POST['narration_type'], $_POST['running_time'], $_POST['zip_file_size'], $_POST['catalog_date'], $_POST['website_link'], $_POST['id']); $updated->update(); } elseif (isset($_POST['find'])) { $searched = new Recording($_POST['title']); $searched->find(); } elseif (isset($_POST['list'])) { $listed = new Recording(); $listed->recording_list(); } else { echo 'Please enter information into the form.'; } ?> <html> <head> <title>LibriVox Recordings</title> </head> <body> To CREATE a New Recording Entry in the Database:<br/><br/> <form method="POST" action="">