Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- if (isset($_GET["id"]))
- {
- try
- {
- $query = $dbh->prepare("SELECT * FROM `ZineDB`.`Magazine`
- WHERE `ZineDB`.`Magazine`.`Magazine_ID` = :id");
- $query->execute(array(':id' => $_GET["id"]));
- }catch (PDOException $pdoe) {
- echo $pdoe->getMessage();
- }
- $result = $query->fetchAll();
- foreach ($result as $index => $row)
- {
- ?><p><h2><?php echo "{$row["Name"]} Issue #{$row["Issue"]}
- released in {$row["Date"]} with a headline of \"{$row["Headline"]}\""?></h2></p>
- <pre><img src="<?php print "images/" . $row["Image"]?>"
- alt="<?php print $row["Name"]?>"
- width="400" height="510" /></pre><?php
- try
- {
- $query = $dbh->prepare("SELECT *
- FROM `ZineDB`.`Article`, `ZineDB`.`Magazine`, `ZineDB`.`MagazineArticle`
- WHERE `ZineDB`.`Magazine`.`Magazine_ID` = :id
- AND `ZineDB`.`Magazine`.`Magazine_ID` = `ZineDB`.`MagazineArticle`.`Magazine_ID`
- AND `ZineDB`.`Article`.`Article_ID` = `ZineDB`.`MagazineArticle`.`Article_ID`
- ORDER BY `Title` ASC");
- $query->execute(array(':id' => $_GET["id"]));
- }catch (PDOException $pdoe) {
- echo $pdoe->getMessage();
- }
- $result = $query->fetchAll();
- if (!$result)
- {
- ?><br/><pre><?php echo "No articles have been submitted for this magazine."?></pre><?php
- }
- else
- {
- foreach ($result as $index => $row)
- {
- ?><br/><li><?php echo "{$row["Title"]} by {$row["Author"]} on {$row["Topic"]}"?>
- <pre></pre></li><?php
- }
- $count = count($result);
- ?><br/><pre><?php
- if ($count == 1) {
- echo "This magazine contains $count article."?></pre><?php
- }
- else {
- echo "This magazine contains $count articles.";
- }
- }
- }
- }
- else
- {
- try
- {
- //Querying for the latest magazine avaiable
- //so that it can be displayed on this page by default.
- $query = $dbh->prepare ("SELECT *
- FROM `Magazine`
- ORDER BY `Issue` DESC
- LIMIT 1");
- $query->execute ();
- }catch (PDOException $pdoe) {
- echo $pdoe->getMessage();
- }
- $result = $query->fetchAll();
- //Display it.
- foreach ($result as $index => $row)
- {
- $Magazine_ID = $row["Magazine_ID"];
- ?>
- <p><h2>
- <?php echo "{$row["Name"]} Issue #{$row["Issue"]}
- released in {$row["Date"]} with a headline of \"{$row["Headline"]}\""?>
- </h2></p>
- <td align="center">
- <a href="magazine_gallery.php?id=<?php echo urlencode($row["Magazine_ID"])?>" color="#8D0D19">
- <center><?php echo "{$row["Name"]} #{$row["Issue"]}"?></center>
- <img src="<?php print "images/" . $row["Image"]?>"
- alt="<?php print $row["Name"]?>"
- width="100" height="125" />
Add Comment
Please, Sign In to add comment