Got some problem with my code here I can't seem to get for each $data row to get the comments per post in there, think i need some input from some one that know what they are doing PHP and SQL is quite new to me, I'm more of a Designer type html jquery and CSS.
<?php
$sql = "SELECT * FROM blog ORDER BY date DESC";
$num_results_per_page = 3;
$num_page_links_per_page = 5;
$pg_param = "#news"; // Ex: &q=value
pagination($sql, $num_results_per_page, $num_page_links_per_page, $pg_param);
if($pg_error == '')
{
if(mysql_num_rows($pg_result) > 0)
{
while($data = mysql_fetch_assoc($pg_result))
{
?>
<div class="type-date">
<div class="blog-type"><img src="images/blog-text.png" alt=""></div>
<div class="blog-date"><h5><?php echo $data["day"]?></h5><h5><?php echo $data["month"]?></h5></div>
</div>
<h2><a href="?bid=<?php echo $data["id"].'#news'?>"><?php echo $data["title"] ?></a></h2>
<?php
$blogcontent = substr
($data["body"],0,600).'....<div style="margin-top:20px"><br><a class="newave-button medium color" href="?bid='.$data["id"].'#news">L?s vidare!</a></div>';
echo $data['ID'].'<br>';
echo '<div style="margin-left:80px;">'.$blogcontent.'</div>';
This part i want to get number of comments for eatch row it creats the blog post.
$resultblogs = mysql_query("SELECT * FROM blog");
while($rowblogs = mysql_fetch_array( $resultblogs )) {
$blogid = $rowblogs['id'];
$blog_comment=mysql_query("Select * from comments WHERE bid='$blogid' AND verify='1'");
$blog_comment_count=mysql_num_rows($blog_comment);
echo $blog_comment_count; }
echo '<hr>';
}
Don't know what i done wrong here i get the code in line like 05332 instead of each number on each post.
echo $pagination_output;
}
else
{
echo 'Inga resultat funna!';
}
}
else
{
echo $pg_error; //display any errors, you can remove this if you want.
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…