-
Notifications
You must be signed in to change notification settings - Fork 2
/
blogpost.php
executable file
·63 lines (54 loc) · 1.43 KB
/
blogpost.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<?php
class BlogPost
{
public $id;
public $title;
public $post;
public $author;
public $tags;
public $datePosted;
function __construct($inId=null, $inTitle=null, $inPost=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 username FROM people WHERE id = " . $inAuthorId);
$row = mysql_fetch_assoc($query);
$this->author = $row["username"];
}
$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;
}
function update(){
}
}
?>