Stellar
13 Mar 2009, 08:21 PM
I'm having trouble separating an element from an array that I've taken from the database.
here is how it currently displays.....
Title one
2009-03-08 20:53:25 new comment by UserID4
Title Two
2009-03-09 01:35:29 new comment by UserID4
Title Two
2009-03-09 01:39:08 new comment by UserID4
Title Three
2009-03-10 22:26:54 new comment by UserID10
But want it to display:
if Entry_ID's are identical, display the corresponding Entry_Title only once with the rest of the info following
as below...
Title one
2009-03-08 20:53:25 new comment by 4
Title Two
2009-03-09 01:35:29 new comment by 4
2009-03-09 01:39:08 new comment by 4
Title Three
2009-03-10 22:26:54 new comment by 10
Here is a print_r of the arrays.....from my query:"SELECT Entry_Title, Entry_Date, comment.Dream_ID, Comment_Date, comment.User_ID FROM comment, entry WHERE comment.Entry_ID=entry.Entry_ID AND dentry.User_ID=$User_ID AND Comment_Read='FALSE'";
Array
(
[Entry_Title] => Title One
[Entry_Date] => 2009-02-26
[Entry_ID] => 31
[Comment_Date] => 2009-03-08 20:53:25
[User_ID] => 4
)
Array
(
[Entry_Title] => Title Two
[Entry_Date] => 2009-02-26
[Entry_ID] => 27
[Comment_Date] => 2009-03-09 01:35:29
[User_ID] => 4
)
Array
(
[Entry_Title] => Title Two
[Entry_Date] => 2009-02-26
[Entry_ID] => 27
[Comment_Date] => 2009-03-09 01:39:08
[User_ID] => 4
)
Array
(
[Entry_Title] => Title Three
[Dream_Date] => 2009-02-26
[Entry_ID] => 25
[Entry_Date] => 2009-03-10 22:26:54
[User_ID] => 10
)
Here is my function...
protected function displayNewComments()
{
$new_comment = $this->model->getReadComment($_SESSION['User_ID']);
$html ='<div id="user">'."\n";
$html .="<div class='entry_header_space'>".$new_comment."</div>";
echo $html;
$rso=$this->model->getUnreadComments($_SESSION['User_ID']);
while($comments=$rso->fetch_assoc())
{
$html="<h2>".$comments['Entry_Title']."</h2>";
$html .=$comments['Comment_Date'] ." new comment by ".$comments['User_ID'] ;
echo $html;
}
(I've tried various things but none of them work quite right.)
here is how it currently displays.....
Title one
2009-03-08 20:53:25 new comment by UserID4
Title Two
2009-03-09 01:35:29 new comment by UserID4
Title Two
2009-03-09 01:39:08 new comment by UserID4
Title Three
2009-03-10 22:26:54 new comment by UserID10
But want it to display:
if Entry_ID's are identical, display the corresponding Entry_Title only once with the rest of the info following
as below...
Title one
2009-03-08 20:53:25 new comment by 4
Title Two
2009-03-09 01:35:29 new comment by 4
2009-03-09 01:39:08 new comment by 4
Title Three
2009-03-10 22:26:54 new comment by 10
Here is a print_r of the arrays.....from my query:"SELECT Entry_Title, Entry_Date, comment.Dream_ID, Comment_Date, comment.User_ID FROM comment, entry WHERE comment.Entry_ID=entry.Entry_ID AND dentry.User_ID=$User_ID AND Comment_Read='FALSE'";
Array
(
[Entry_Title] => Title One
[Entry_Date] => 2009-02-26
[Entry_ID] => 31
[Comment_Date] => 2009-03-08 20:53:25
[User_ID] => 4
)
Array
(
[Entry_Title] => Title Two
[Entry_Date] => 2009-02-26
[Entry_ID] => 27
[Comment_Date] => 2009-03-09 01:35:29
[User_ID] => 4
)
Array
(
[Entry_Title] => Title Two
[Entry_Date] => 2009-02-26
[Entry_ID] => 27
[Comment_Date] => 2009-03-09 01:39:08
[User_ID] => 4
)
Array
(
[Entry_Title] => Title Three
[Dream_Date] => 2009-02-26
[Entry_ID] => 25
[Entry_Date] => 2009-03-10 22:26:54
[User_ID] => 10
)
Here is my function...
protected function displayNewComments()
{
$new_comment = $this->model->getReadComment($_SESSION['User_ID']);
$html ='<div id="user">'."\n";
$html .="<div class='entry_header_space'>".$new_comment."</div>";
echo $html;
$rso=$this->model->getUnreadComments($_SESSION['User_ID']);
while($comments=$rso->fetch_assoc())
{
$html="<h2>".$comments['Entry_Title']."</h2>";
$html .=$comments['Comment_Date'] ." new comment by ".$comments['User_ID'] ;
echo $html;
}
(I've tried various things but none of them work quite right.)