PHP Nuke Nederland
 
•   Home  •  Downloads  •  Your Account  •  Forums  •
PHP-Nuke Nederland: Forums

PHP-Nuke Nederland :: View topic - [OPGELOST] Aantal comments weergeven in profiel
 Forum FAQ  •   Search   •  Memberlist  •  Usergroups   •  Register   •    •  Profile  •  Log in to check your private messages  •  Log in

 
Post new topicReply to topic
View previous topic Log in to check your private messages View next topic
Author Message
Eboards
Gevorderd
Gevorderd


Joined: Sep 10, 2006
Posts: 116

PostPosted: Fri 01 Feb 2008 1:24 Reply with quoteBack to top

Is het mogelijk om het aantal comments op nieuwsartikels per gebruiker te tellen en dit weer te geven in het profiel van die gebruiker?

Hoe tel ik het aantal comments van die gebruiker in de database?


Last edited by Eboards on Wed 19 Mar 2008 22:14; edited 1 time in total
View user's profileSend private message
BlueLion
Administrator
Administrator


Joined: Aug 21, 2004
Posts: 2836

PostPosted: Tue 05 Feb 2008 7:17 Reply with quoteBack to top

Code:

SELECT
  name, COUNT(*)
FROM
  `nuke_comments`
GROUP BY
  `name`


Probleem is hier dat `name` werkelijk de naam is van diegene die een comment achterliet zoals dit in de user tabel staat. Geen user_id dus. Wanneer je het wijzigen van namen toestaat, of handmatig hebt gedaan, is er geen touw meer aan vast te knopen wie hoeveel comments heeft geplaatst. Wanneer dit alles niet het geval is kan je `name` koppelen aan `username` uit de users tabel.


BL

_________________
Te Lezen: Forum Regels | Te Gebruiken: Forum Zoek Functie
Aanbevolen PHP-Nuke versie: PHP-Nuke 7.6pl3.1!
Aanbevolen Security AddOn: Nuke Sentinel™
View user's profileSend private messageSend e-mailVisit poster's website
Eboards
Gevorderd
Gevorderd


Joined: Sep 10, 2006
Posts: 116

PostPosted: Wed 06 Feb 2008 1:36 Reply with quoteBack to top

Dank je om me op weg te zetten!

Maar ik krijg een melding:
Resource id#47

Geen idee wat dit wil zeggen...

Hoe moet ik dit precies aanpakken:
[php:1:0be291472e]$sql9 = "SELECT name, COUNT(*) FROM `nuke_comments` GROUP BY `name`";
$comments = $db->sql_query($sql9);
$row = $db->sql_fetchrow($comments);[/php:1:0be291472e]

En wat moet ik aan de global toevoegen? $comments?
En dan bij de opvraging gewoon $comments zetten?
View user's profileSend private message
BlueLion
Administrator
Administrator


Joined: Aug 21, 2004
Posts: 2836

PostPosted: Wed 06 Feb 2008 8:17 Reply with quoteBack to top

Dat gaat niet goed.

Code:

$sql9 = $db->sql_query("

SELECT
   name,
   COUNT(*) AS totalcomments
FROM
   `nuke_comments`
GROUP BY
   `name`
)";

$row = $db->sql_fetchrow($sql9);
$comments = intval($row['totalcomments']);



BL

_________________
Te Lezen: Forum Regels | Te Gebruiken: Forum Zoek Functie
Aanbevolen PHP-Nuke versie: PHP-Nuke 7.6pl3.1!
Aanbevolen Security AddOn: Nuke Sentinel™
View user's profileSend private messageSend e-mailVisit poster's website
Eboards
Gevorderd
Gevorderd


Joined: Sep 10, 2006
Posts: 116

PostPosted: Thu 07 Feb 2008 7:19 Reply with quoteBack to top

Ok, dit heb ik aan index.php van Your_Account toegevoegd.

Maar als ik nu ergens in de tekst, $comments invoeg, dan vraagt hij niets op en geeft hij gewoon "$comments" weer.

Sorry Embarassed dit is de eerste keer dat ik iets met databasecodes uitvoer. Embarassed
View user's profileSend private message
Eboards
Gevorderd
Gevorderd


Joined: Sep 10, 2006
Posts: 116

PostPosted: Mon 25 Feb 2008 0:31 Reply with quoteBack to top

Ik geraak er niet echt uit... wellicht zie ik iets voor de hand liggends over het hoofd Question
View user's profileSend private message
BlueLion
Administrator
Administrator


Joined: Aug 21, 2004
Posts: 2836

PostPosted: Sun 02 Mar 2008 6:04 Reply with quoteBack to top

Hoe ziet de rest van je code eruit?


BL

_________________
Te Lezen: Forum Regels | Te Gebruiken: Forum Zoek Functie
Aanbevolen PHP-Nuke versie: PHP-Nuke 7.6pl3.1!
Aanbevolen Security AddOn: Nuke Sentinel™
View user's profileSend private messageSend e-mailVisit poster's website
Eboards
Gevorderd
Gevorderd


Joined: Sep 10, 2006
Posts: 116

PostPosted: Wed 19 Mar 2008 22:08 Reply with quoteBack to top

Het is intussen gelukt met de volgende code:

[php:1:4673f3c815]$comments = $db->sql_fetchrow($db->sql_query("SELECT name, COUNT(*) AS totalcomments FROM ".$user_prefix."_comments WHERE name='$username' GROUP BY `name`"));
$totalcomments = intval($comments['totalcomments']);
echo "$totalcomments ".nieuwsreacties."<br>";[/php:1:4673f3c815]

BEDANKT!
View user's profileSend private message
Krammetje
Gevorderd
Gevorderd


Joined: Sep 12, 2006
Posts: 66

PostPosted: Sat 22 Mar 2008 20:49 Reply with quoteBack to top

Waar moet ik de code precies invoegen? Ik las in index.php bij Your Account, maar waar precies?
View user's profileSend private message
Eboards
Gevorderd
Gevorderd


Joined: Sep 10, 2006
Posts: 116

PostPosted: Tue 25 Mar 2008 9:25 Reply with quoteBack to top

Hallo Krammetje

Ondertussen heb ik de code wat uitgebreid naar:
[php:1:cbc4af4242] $comments = $db->sql_fetchrow($db->sql_query("SELECT name, COUNT(*) AS totalcomments FROM ".$user_prefix."_comments WHERE name='$username' GROUP BY `name`"));
$totalcomments = intval($comments['totalcomments']);
if ($comments['totalcomments']) { echo "<br>$totalcomments"; }

if ($totalcomments > 1) {
print " nieuwsreacties";
} elseif ($totalcomments == 1) {
print " nieuwsreactie";
} else {
print "";[/php:1:cbc4af4242]

En deze heb ik staan na de volgende code:

[php:1:cbc4af4242]username_online = $row2[uname];
if ($username_online == "") {
$online = _OFFLINE;
} else {
$online = _ONLINE;
}
echo "<b>"._USERSTATUS.":</b><br>$online<br>[/php:1:cbc4af4242]

Maar je kunt natuurlijk kiezen waar precies je het plaatst in de function userinfo section.
View user's profileSend private message
Display posts from previous:      
 Donaties   Adverteren 
Wilt u het forum steunen, dan kunt u nu eenvoudig doneren met PayPal.
Post new topicReply to topic
View previous topic Log in to check your private messages View next topic
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 © 2001, 2005 phpBB Group

Web site powered by PHP-Nuke

All logos and trademarks in this site are property of their respective owner. The comments are property of their posters, all the rest © 2004-2008 by BlueLion.
SEO enhanced with the Sitemapper script
You can syndicate our news using the file backend.php or ultramode.txt
Powered by PHP Powered by MySQL Apache Webserver Valid robots.txt
PHP-Nuke Copyright © 2004 by Francisco Burzi. This is free software, and you may redistribute it under the GPL. PHP-Nuke comes with absolutely no warranty, for details, see the license.
Pagina rendering: 0.08 seconden


[Valid News RSS]

RSS Feeds:
[RSS 2.0 News Feed]
[RSS 2.0 Download Feed]
[RSS 2.0 Forum Feed]
[RSS 2.0 Link Feed]
:: fisubsilver shadow phpbb2 style by Daz :: PHP-Nuke theme by BlueLion ::