 |
boardom b2 message board
|
View previous topic :: View next topic |
Author |
Message |
JagEsquire
Joined: 03 Jan 2003 Posts: 5 Location: Canada
|
Posted: Fri Jan 03, 2003 10:26 am Post subject: [Request] Headline comment total |
|
|
Hi there everyone, thank you all for all the help you have silently provided me. But I have finally run into a difficulty that hasn't been answered here in the discussion forum.
I borrowed a hack from GamerZ that he posted here. And I've played with it a bit to make it look like I want it to. Here is a sample of what I have running.
Code: |
<?
dbconnect();
$result = mysql_query("select ID, DATE_FORMAT(post_date, '%d.%m.%Y'), post_title FROM b2posts ORDER BY post_date DESC LIMIT 8");
while(list($ID, $date, $title) = mysql_fetch_row($result))
{echo "<div align=\"center\"><a href=\"tsmokeblog.php?p=$ID\"><font face=\"verdana\" size=\"4\">$title</a><br/></font></div><div align=\"center\"><font face=\"verdana\" size=\"1\">posted on $date</font></div><hr width=\"60%\"/>";}
?>
|
Now I would like to pull back the the total number of comments that have been posted to each main blog and display that total on the main page. You can see what I am shooting for by looking at how my page is setup. TransparentSmoke. All that shows on my main page is the title of each post and the date posted, I would like to add the number of comments made to them to this area as well so infrequent visitors will click on the busy headlines.
Thank you
JagEsquire |
|
Back to top |
|
 |
mikelittle
Joined: 11 May 2002 Posts: 376 Location: UK
|
Posted: Sun Jan 19, 2003 10:13 pm Post subject: |
|
|
Ho JaqEsquire,
Try this (note: I've reformatted for clarity)
[php:1:4338136254]
<?php
dbconnect();
$result = mysql_query("select ID, DATE_FORMAT(post_date, '%d.%m.%Y'), post_title, " .
" count(comment_ID) as comment_count " .
" FROM b2posts LEFT JOIN b2comments on comment_post_ID = ID " .
" GROUP BY ID " .
" ORDER BY post_date DESC LIMIT 36");
while(list($ID, $date, $title, $comment_count) = mysql_fetch_row($result)) {
$comment_text = (($comment_count == 0) ? "no comments" : (($comment_count > 1) ? "$comment_count comments" : "1 comment"));
?>
<div align="center">
<a href="tsmokeblog.php?p=<?= $ID ?>"><font face="verdana" size="4"><?=$title?></a><br/></font>
</div>
<div align="center">
<font face="verdana" size="1">posted on <?=$date?> (<?=$comment_text?>)</font>
</div>
<hr width="60%"/>
<?php
}
?>
[/php:1:4338136254]
Hope this helps,
Mike _________________ Mike Little
http://zed1.com/journalized/
"Share what you know. Learn what you don't." |
|
Back to top |
|
 |
JagEsquire
Joined: 03 Jan 2003 Posts: 5 Location: Canada
|
Posted: Tue Jan 21, 2003 3:04 am Post subject: I'm in your debt |
|
|
It's perfect, beautifull.
I was begining to lose hope. I watched each day as new posts bumped mine off the top of the page, and was tempted on ocation to go in and read my own post to up the number of views to create interest, or maybe post to myself and raise its level on the page.
I'm glad my online morals held me back. I'm glad there are people like you willing to spend the time to help.
I'll have a few faces to rub on this one tomorrow. A couple of guys from work took a look and convinced me that I would have to write a new function to make this work. You've proved your genious over them (and me).
Thank You very much for your time and effort.
JagEsquire |
|
Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB 2 © 2001, 2002 phpBB Group
|