Guest User

Untitled

a guest
Oct 21st, 2017
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.85 KB | None | 0 0
  1. <?php
  2.     if (isset($_GET["id"]))
  3.     {
  4.         try
  5.         {
  6.             $query = $dbh->prepare("SELECT * FROM `ZineDB`.`Magazine`
  7.                                    WHERE `ZineDB`.`Magazine`.`Magazine_ID` = :id");
  8.             $query->execute(array(':id' => $_GET["id"]));
  9.         }catch (PDOException $pdoe) {
  10.             echo $pdoe->getMessage();
  11.         }
  12.         $result = $query->fetchAll();
  13.         foreach ($result as $index => $row)
  14.         {
  15.             ?><p><h2><?php echo "{$row["Name"]} Issue #{$row["Issue"]}
  16.            released in {$row["Date"]} with a headline of \"{$row["Headline"]}\""?></h2></p>
  17.             <pre><img src="<?php print "images/" . $row["Image"]?>"
  18.                                              alt="<?php print $row["Name"]?>"
  19.                                              width="400" height="510" /></pre><?php        
  20.             try
  21.             {
  22.                 $query = $dbh->prepare("SELECT *
  23.                                        FROM `ZineDB`.`Article`, `ZineDB`.`Magazine`, `ZineDB`.`MagazineArticle`
  24.                                        WHERE `ZineDB`.`Magazine`.`Magazine_ID` = :id
  25.                                        AND `ZineDB`.`Magazine`.`Magazine_ID` = `ZineDB`.`MagazineArticle`.`Magazine_ID`
  26.                                        AND `ZineDB`.`Article`.`Article_ID` = `ZineDB`.`MagazineArticle`.`Article_ID`
  27.                                        ORDER BY `Title` ASC");
  28.                 $query->execute(array(':id' => $_GET["id"]));
  29.             }catch (PDOException $pdoe) {
  30.                 echo $pdoe->getMessage();
  31.             }
  32.  
  33.             $result = $query->fetchAll();
  34.             if (!$result)
  35.             {
  36.                 ?><br/><pre><?php echo "No articles have been submitted for this magazine."?></pre><?php
  37.             }
  38.             else
  39.             {
  40.                 foreach ($result as $index => $row)
  41.                 {
  42.                     ?><br/><li><?php echo "{$row["Title"]} by {$row["Author"]} on {$row["Topic"]}"?>
  43.                         <pre></pre></li><?php
  44.                 }
  45.                 $count = count($result);
  46.                 ?><br/><pre><?php
  47.                                 if ($count == 1) {
  48.                                     echo "This magazine contains $count article."?></pre><?php
  49.                                 }
  50.                                 else {
  51.                                     echo "This magazine contains $count articles.";
  52.                                 }
  53.             }
  54.         }
  55.     }
  56.     else
  57.     {
  58.         try
  59.         {
  60.             //Querying for the latest magazine avaiable
  61.             //so that it can be displayed on this page by default.
  62.             $query = $dbh->prepare ("SELECT *
  63.                                    FROM `Magazine`
  64.                                    ORDER BY `Issue` DESC
  65.                                    LIMIT 1");
  66.             $query->execute ();
  67.         }catch (PDOException $pdoe) {
  68.             echo $pdoe->getMessage();
  69.         }
  70.         $result = $query->fetchAll();
  71.         //Display it.
  72.         foreach ($result as $index => $row)
  73.         {
  74.             $Magazine_ID = $row["Magazine_ID"];
  75.             ?>
  76.             <p><h2>
  77.             <?php echo "{$row["Name"]} Issue #{$row["Issue"]}
  78.                released in {$row["Date"]} with a headline of \"{$row["Headline"]}\""?>
  79.             </h2></p>
  80.                 <td align="center">
  81.                     <a href="magazine_gallery.php?id=<?php echo urlencode($row["Magazine_ID"])?>" color="#8D0D19">
  82.                         <center><?php echo "{$row["Name"]} #{$row["Issue"]}"?></center>
  83.                         <img src="<?php print "images/" . $row["Image"]?>"
  84.                                                              alt="<?php print $row["Name"]?>"
  85.                                                              width="100" height="125" />
Add Comment
Please, Sign In to add comment