Forum Moderators: coopster
<?php
(connection string here)if (mysqli_connect_errno()) {
printf("Connect Failed: %s\n", mysqli_connect_error());
exit();
} else {
$query = "SELECT title, date, main, name, comment FROM blog_board RIGHT JOIN comments ON blog_board.blog_id = comments.blog_id";
$res = mysqli_query($mysqli, $query);
if($res) {
while ($newArray = mysqli_fetch_array($res, MYSQLI_ASSOC)) {
$id = $newArray['blog_id'];
$date = $newArray['date'];
$title = $newArray['title'];
$main = $newArray['main'];
$name = $newArray['name'];
$comment = $newArray ['comment'];
echo "<div id='border'>";
echo "<div class='bg'><div class='subject'>".$id." ".$title. "
" .$date."</div></div>";
echo "<div class='body'><div class='body'>".$main."</div><br><br>";
echo "<div>".$name."<br><br>".$comment."";
echo "</div><br>";
}
} else {
printf("Could not retrieve records: %s\n", mysqli_error($mysqli));
}
mysqli_free_result($res);
mysqli_close($mysqli);
}
?>
and what is happening it is returning only one row, and also i wanted it to only display the news and comments based on the id it related to e.g;
when a user clicks view comments on news feeds where (id=1) i want news feeds and comments that have that id of 1 to be displayed.
at the moment news 1 is coming up on link 1 (as it should)
and also on link 2 (as it shouldn't)
Many Thanks all