Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- include 'BlogPost.php';
- $connection = mysql_connect('mysql11.000webhost.com', 'a5273704_MtXing', 'MyBlog1') or die ("<img src='/Error.png' alt='ERROR'/><h1 class='Error'>BIG SCARY ERROR, GO!</h1><p class='Error'>Yeah... Whoops. Something went wrong when logging into the database. Sorry about that.</p>");
- $database = "a5273704_Blog";
- mysql_select_db($database, $connection) or die ("<img src='/Error.png' alt='ERROR'/><h1 class='Error'>BIG SCARY ERROR, GO!</h1><p class='Error'>Yeah... Whoops. Something went wrong when loading the database. Sorry about that.</p>");
- function GetBlogPosts($inId =null, $inTagId =null)
- {
- if (!empty($inId)){
- $query = mysql_query("SELECT * FROM blog_posts WHERE id = " . $inId . " ORDER BY id DESC");
- }
- else if (!empty($inTagId)){
- $query = mysql_query("SELECT blog_posts.* FROM blog_post_tags LEFT JOIN (blog_posts) ON (blog_post_tags.postID = blog_posts.id) WHERE blog_post_tags.tagID =" . $tagID . " ORDER BY blog_posts.id DESC");
- } else{
- $query = mysql_query("SELECT * FROM blog_posts ORDER BY id DESC");
- }
- $postArray = array();
- while ($row = mysql_fetch_assoc($query)){
- $myPost = new BlogPost($row["id"], $row['title'], $row['post'], $row['postfull'], $row["author_id"], $row['date_posted']);
- array_push($postArray, $myPost);
- }
- return $postArray;
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement