. */ /** * getNewsComments($id) * Function getting an array of comments for posted news * @param id - news_id cooresponding to `bayonet_news` * @return - associative array of comments */ function getNewsComments($id){ global $db; $result = $db->Query("SELECT c.comment_id, c.news_id, c.author_id, c.message, c.date, u.username AS author, u.avatar as avatar ". "FROM `bayonet_news_comments` AS c ". "LEFT OUTER JOIN `mybb_users` AS u ON u.uid = c.author_id ". "WHERE c.news_id = '$id' ". "ORDER BY date ASC"); $comments = $db->Fetch($result); /* while(($row = $db->Fetch($result)) != false) { $comments[] = $row; } $db->Free($result); */ return $comments; } /** * displayComments($data) * Function that takes an array of comments and displays them in html * @param data - associative array of comments from the database */ function displayComments($data){ date_default_timezone_set("America/New_York"); OpenContent(); ?>

User Comments

Add Yours
  1. "; }else{ echo ""; } ?>

    0){ echo "{$comment['author']}"; }else{ echo "Guest"; } ?>

  2. "; commentForm(); CloseContent(); } /** * getNumOfComments($id) * Function that gets the number of comments a news post has * @param id - news_id cooresponding to `bayonet_news` */ function getNumOfComments($id){ global $db; $result = $db->Query("SELECT `comment_id` FROM `bayonet_news_comments` WHERE `news_id` = '$id'"); return $db->Rows($result); } /** * getNumOfComments($id) * Function that gets the desired news from the database and returns it as an array * @param id - (optional) news_id cooresponding to `bayonet_news` */ function getNews($id = NULL, $limit = NULL, $index = 0){ global $db; $query = "SELECT n.news_id, n.title, n.message, n.date, n.category_id, u.username AS author, c.name AS catname, c.image AS catimage ". "FROM `bayonet_news` AS n ". "INNER JOIN `bayonet_news_categories` AS c ON c.category_id = n.category_id ". "LEFT OUTER JOIN `mybb_users` AS u ON u.uid = n.author_id "; if(isset($id)){ $query = $query."WHERE n.news_id = '$id' "; }else{ $query = $query."ORDER BY date DESC"; if($index > 0) $query = $query." LIMIT $index, $limit"; else if($limit !=NULL) $query = $query." LIMIT $limit"; } decho($query); $result = $db->Query($query); $data = $db->Fetch($result); return $data; } /** * displayNews($data) * Function that takes an array of news and displays it as html * @param data - associative array of news from the database */ function displayNews($data){ date_default_timezone_set("America/New_York"); if(empty($data)){ ReportError("Sorry, we found no news using these parameters."); echo "
    "; } foreach($data as $news) { $numComments = getNumOfComments($news['news_id']); OpenContent(); ?>
    Posted by:
    <?php echo $news['catname']; ?>
    "; } } /** This was coded on Coda with a MacBook Pro **/ function commentForm(){ global $db; if(isset($_POST['processed'])) { $comment = stripslashes($_POST['comment']); $author_id = stripslashes($_POST['author']); echo "Author: {$author_id}
    Comment: {$comment}
    "; echo "Your comment has been processed. Please wait.
    "; } $cur_user_id = 0; //testing variable, until i get the login system working for this $logged_in = false; ?>

    Add Your Comment

    1. "; }else{ echo ""; } ?>