Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!--Previously we were retrieving an array of stories, but here we're only getting one.-->
- <?php
- require_once 'classes/Connection.php';
- require_once 'classes/Story.php';
- require_once 'classes/Util.php';
- try{
- /*The $_GET method checks the URL for any 'id' parameters.*/
- var_dump($_GET['id']);
- $story = Story::find($_GET['id']);
- if($story === false)
- {
- throw new Exception("Story not found");
- }
- else{
- /*These are the same as we have in our test.php foreach loop, just this time we only want to see them once.*/
- $category = Util::selectById('categories',$story->category_id);
- $author = Util::selectById('authors',$story->author_id);
- }
- }
- catch(Exception $e){
- die("Exception: " . $e->getMessage());
- }
- ?>
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <title>News Site</title>
- <link rel="stylesheet" type="text/css" href="css/grid.css">
- <link rel="stylesheet" type="text/css" href="css/style.css">
- </head>
- <body>
- <div>
- <label>Headline: </label>
- <? = $story->headline ?>
- </div>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement