Wanneer ik een reactie toevoeg aan een nieuwsbericht
werkt prima. Totdat ik 2 of meer reacties er aan toevoegd me webpagina ziet er dan zo uit
News.title
News.date
News.message
Comment.name
Comment.mail
Comment.message
News.title
News.date
News.message
Comment.name(2)
Comment.mail(2)
Comment.message(2)
zoals je ziet news.title, News.date, news.message komen dus dubbel weer, terwijl ik ze maar 1 echo.
erg irritant als je natuurlijk als je 5 reacties heb, dan zie je 5x het bericht .
Hoe kan ik dat oplossen, dat hij gewoon 1x mijn nieuwsbericht geeft en daaronder de geschreven reacties.
code
<?php
$news_id = mysql_real_escape_string($_GET['id']);
$comment_id = mysql_real_escape_string($_GET['id']);
$sql = "SELECT comments.comment_id, comments.comment_name, comments.comment_mail, comments.comment_message, news.news_id, news.news_title, news.news_date, news.news_message FROM comments RIGHT JOIN news ON news.news_id = comments.comment_news_id WHERE news.news_id = ". $news_id." ORDER BY news.news_id";
$result = mysql_query( $sql )
or die( mysql_error() );
if( mysql_num_rows( $result) == 0 )
{
echo "Result = 0";
}
else
{
// While maken
while(
$output = mysql_fetch_assoc( $result) )
{
{
echo '<p class="title">// <a href="getNewsMessage.php?id=' . $output['news_id'] .'">'.$output['news_title'].'</a></p>';
echo '<p class="date">gepost op ' . dutchdate($output['news_date']) . '</p>';
echo '<p class="message">' . htmlspecialchars_decode($output['news_message']) . '</p>';
echo "\n\n";
echo '<p class="comment">' . htmlspecialchars_decode($output['comment_name']) . '</p>';;
echo '<p class="comment">' . htmlspecialchars_decode($output['comment_mail']) . '</p>';
echo '<p class="comment">' . htmlspecialchars_decode($output['comment_message']) . '</p>';
echo "\n\n";
}
}
}
?>
571 views