Created
June 29, 2011 06:06
-
-
Save Sadin/1053250 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| $connection = mysql_connect('localhost', 'root', '33456zs') or die ("<p class='error'>Sorry, we were unable to connect to the database server.</p>"); | |
| $database = "fuelapp"; | |
| mysql_select_db($database, $connection) or die ("<p class='error'>Sorry, we were unable to connect to the database.</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['dateposted']); | |
| array_push($postArray, $myPost); | |
| } | |
| return $postArray; | |
| } | |
| ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment