coppermine-gallery.com/forum

Support => cpg1.3.x Support => Older/other versions => cpg1.3 Installation & Setup => Topic started by: darkkiller on October 10, 2005, 10:58:36 PM

Title: count all comments in one album ?
Post by: darkkiller on October 10, 2005, 10:58:36 PM
How can i count with php all comments in one album ?
Title: Re: count all comments in one album ?
Post by: Nibbler on October 10, 2005, 10:59:38 PM
Please explain what you are trying to accomplish.
Title: Re: count all comments in one album ?
Post by: darkkiller on October 10, 2005, 11:02:04 PM
on my main website i give the last 3 albums out

<?php
$query 
"SELECT * FROM party31gallery_albums ORDER BY aid DESC LIMIT 3";
$result=mysql_query($query);
while (
$daten=mysql_fetch_array($resultMYSQL_ASSOC))
{
    
$datum substr($daten[title], -10);
    
$title substr($daten[title], 0, -10);


    echo 
"<tr>";
    echo 
"<td width=15% class=row2>$datum</td>";
    echo 
"<td width=45% class=row2><a href=http://party31.web.my-ct.de/party31/gallery/thumbnails.php?album=$daten[aid]><font color=#000000 size=2>$title</a></td>";
    echo 
"<td width=15% class=row2> </td>";
    echo 
"</tr>";
}
?>


and now i want to give the number of all comments in one album out.
But i dont know what the MySql command is ?
Title: Re: count all comments in one album ?
Post by: Nibbler on October 10, 2005, 11:17:38 PM
The statement would be

SELECT COUNT(msg_id) FROM party31gallery_comments AS c INNER JOIN party31gallery_pictures AS p ON p.pid = c.pid WHERE p.aid = n

n = the aid of the album in question.
Title: Re: count all comments in one album ?
Post by: darkkiller on October 10, 2005, 11:27:25 PM
and the whole code with output ?
i dont know how i can give out only the number of all comments...
Title: Re: count all comments in one album ?
Post by: Nibbler on October 10, 2005, 11:33:07 PM

$result = mysql_query("SELECT COUNT(msg_id) FROM party31gallery_comments AS c INNER JOIN party31gallery_pictures AS p ON p.pid = c.pid WHERE p.aid = n");
list($numcom) = mysql_fetch_row($result);
echo "There are $numcom comments in this here album mister";
Title: Re: count all comments in one album ?
Post by: darkkiller on October 10, 2005, 11:39:40 PM
and can i make a graphik which appears when the last comment was 15 minutes ago post. ?
How ?
mhm.. if not .. can i give out the date of the last comment ?


THANK YOU VERY MUCH YOU ARE MY HERO FOR TODAY :):):)