Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class BlogPost{
- public $id;
- public $title;
- public $post;
- public $tags;
- public $datePosted;
- function __construct($inId=null, $inTitle=null, $inPost=null, $inPostFull=null, $inAuthorId=null, $inDatePosted=null){
- $this->id = $inId;
- $this->title = $inTitle;
- $this->post = $inPost;
- $splitDate = explode("-", $inDatePosted);
- $this->datePosted = $splitDate[1] . "/" . $splitDate[2] . "/" . $splitDate[0];
- $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"];
- $query = mysql_query("SELECT * F ROMblog_post_tags WHERE blog_post_tags.blog_post_id = " . $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);
- $postTags = "No Tags";
- $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;
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement