X-Git-Url: https://disinclined.org/git/?a=blobdiff_plain;f=model%2Fnote.php;h=d5ab563d6205d0f2d4e0ef59feda3595382cac70;hb=a99ed12dc9a0d7d02721fa6b781b47116b976e3b;hp=01338be29f03aec67d2537f68b94452abe5d2985;hpb=88919e70ab2efb3d5b543dce06f229eb1da0feb7;p=dylansserver.git diff --git a/model/note.php b/model/note.php index 01338be..d5ab563 100644 --- a/model/note.php +++ b/model/note.php @@ -12,6 +12,7 @@ class note extends model { public $day_posted; public $text; public $number_of_comments; + public $comments; public function __construct() { parent::__construct(); @@ -97,22 +98,19 @@ class note extends model { } public function display_comments() { - echo "
"; + // should be called like $note->comment[0]['author'] $sql= "SELECT date_posted, author, text FROM comments WHERE note = ? ORDER BY date_posted DESC"; $result = $this->query($sql, 'd', $this->id); + $i = 0; foreach ($result as $row => $entry) { - $date_posted = $entry['date_posted']; - $author = $entry['author']; - $text = htmlspecialchars($entry['text']); - $head = "

" . htmlspecialchars($author) . "

"; - echo "
"; - echo $head; - echo $text; - echo "
"; + $this->comment[$i]['date_posted'] = $entry['date_posted']; + $this->comment[$i]['author'] = $entry['author']; + $this->comment[$i]['text'] = htmlspecialchars($entry['text']); + $this->comment[$i]['head'] = "

" . htmlspecialchars($author) . "

"; + $i++; } - echo "
"; } public function display_comment_form() {