Created
June 29, 2011 05:35
-
-
Save Sadin/1053221 to your computer and use it in GitHub Desktop.
blog
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
| index.php | |
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <meta charset="utf-8"> | |
| <title>Sparkz Design</title> | |
| <link rel="stylesheet" type="text/css" href="./assets/css/reset.css" /> | |
| <link rel="stylesheet" type="text/css" href="./assets/css/960.css" /> | |
| <link rel="stylesheet" type="text/css" href="./assets/css/text.css" /> | |
| </head> | |
| <body> | |
| <div class="container_12"> | |
| <div class="grid_12"> | |
| <h1>My Simple Blog</h1> | |
| </div> | |
| <div class="clear"></div> | |
| <div class="grid_8"> | |
| <?php | |
| include 'stuff.php'; | |
| foreach ($blogPosts as $post) | |
| { | |
| echo $post->title . "<br/>"; | |
| } | |
| ?> | |
| </div> | |
| <div id="main"> | |
| <div id="blogPosts"> | |
| </div> | |
| </div> | |
| <div class="clear"></div> | |
| <div class="grid_12"> | |
| Copyright 2011 | Page rendered in {exec_time}s using {mem_usage}mb of memory. | |
| </div> | |
| </div> | |
| </body> | |
| </html> | |
| stuff.php | |
| <?php | |
| class BlogPost | |
| { | |
| public $id; | |
| public $title; | |
| public $post; | |
| public $author; | |
| public $tags; | |
| public $datePosted; | |
| function __construct($inId=null, $inTitle=null, $inPost=null, $inPostFull=null, $inAuthorId=null, $inDatePosted=null) | |
| { | |
| if (!empty($inId)) | |
| { | |
| $this->id = $inId; | |
| } | |
| if (!empty($inTitle)) | |
| { | |
| $this->title = $inTitle; | |
| } | |
| if (!empty($inPost)) | |
| { | |
| $this->post = $inPost; | |
| } | |
| if (!empty($inDatePosted)) | |
| { | |
| $splitDate = explode("-", $inDatePosted); | |
| $this->datePosted = $splitDate[1] . "/" . $splitDate[2] . "/" . $splitDate[0]; | |
| } | |
| if (!empty($inAuthorId)) | |
| { | |
| $query = mysql_query("SELECT first_name, last_name FROM people WHERE id = " . $inAuthorId); | |
| $row = mysql_fetch_assoc($query); | |
| $this->author = $row["first_name"] . " " . $row["last_name"]; | |
| } | |
| $postTags = "No Tags"; | |
| if (!empty($inId)) | |
| { | |
| $query = mysql_query("SELECT tags.* FROM blog_post_tags LEFT JOIN (tags) ON (blog_post_tags.tag_id = tags.id) WHERE blog_post_tags.blog_post_id = " . $inId); | |
| $tagArray = array(); | |
| $tagIDArray = array(); | |
| while($row = mysql_fetch_assoc($query)) | |
| { | |
| array_push($tagArray, $row["name"]); | |
| array_push($tagIDArray, $row["id"]); | |
| } | |
| if (sizeof($tagArray) > 0) | |
| { | |
| foreach ($tagArray as $tag) | |
| { | |
| if ($postTags == "No Tags") | |
| { | |
| $postTags = $tag; | |
| } | |
| else | |
| { | |
| $postTags = $postTags . ", " . $tag; | |
| } | |
| } | |
| } | |
| } | |
| $this->tags = $postTags; | |
| } | |
| } | |
| ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment