Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> [resolved] Individual member counts, how is this possible?
horrorshow
post May 1 2005, 12:02 PM
Post #1


Unregistered









I've searched and searched but couldn't find a topic on this sad.gif Or maybe it's really obvious and everyone knows how to do this except me unsure.gif

What I want to show, is a list of my owned fanlistings and the number of approved and pending members for each. I know this was possible in PHPFanbase, so is it possible for Enth? This was the tutorial for phpfanbase, in case I didn't explain it clearly enough smile.gif
Go to the top of the page
+Quote Post
Luinthoron
post May 1 2005, 04:13 PM
Post #2


Rank #1: Newbie
*

Group: Members
Posts: 14
Joined: 3-April 05
From: Estonia
Member No.: 2,458



Do you mean this?


--------------------
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
horrorshow
post May 2 2005, 05:48 AM
Post #3


Unregistered









No; that's just customizing my owned fanlistings page. What I'd like to show is a page with just fanlisting member counts, like what you can do with phpfanbase like this.

And I can't think of a way to do that sad.gif
Go to the top of the page
+Quote Post
Luinthoron
post May 2 2005, 06:29 AM
Post #4


Rank #1: Newbie
*

Group: Members
Posts: 14
Joined: 3-April 05
From: Estonia
Member No.: 2,458



You probably can't have this separately from the owned listings page, unless you're willing to update the owned listings page manually and use the owned listings template for a page like this.

However, a page exactly like this (although without the collective stats, unless you use the Collective Stats Addon) can be made with the owned listings template.


--------------------
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
Julie
post May 2 2005, 07:14 AM
Post #5


Rank #5: Obsessed
*****

Group: Loyal Members
Posts: 768
Joined: 21-July 03
From: Winnipeg, MB
Member No.: 262



As far as I know, there is not an existing snippet or tutorial for this feature for Enth 3, unless like Luinthoron wrote, you want to use the owned fanlistings template. I wanted the members count for my collective in addition to a more detailed owned fanlistings page, so I wrote the code for it and you are welcome to use it. This code works with or without the collective stats add-on and even works if your fanlistings don't all use the same database. smile.gif

In action at my site: http://new-place.org/members.php

Paste the following code where ever you'd like the table to show up:
CODE
<?php
include 'config.php';
?>

<table>
<!-- customize column headings -->
<tr>
<td>fanlisting</td>
<td>listed</td>
<td>pending</td></tr>
<!-- stop -->

<?php
$get_owned = mysql_query("SELECT * FROM $db_owned WHERE status='2' ORDER BY subject ASC");
while ($row = mysql_fetch_array($get_owned)) {
    $title = $row['title'];
    $subject = $row['subject'];
    $url = $row['url'];
    
    if ($row['dbserver'] == $db_server) {
      $getapprovedcount = mysql_query("SELECT COUNT(*) as approvedcount FROM $row[dbtable] WHERE pending='0'");
      $approvedcount = mysql_result($getapprovedcount, 0, "approvedcount");
      $getpendingcount = mysql_query("SELECT COUNT(*) as pendingcount FROM $row[dbtable] WHERE pending='1'");
      $pendingcount = mysql_result($getpendingcount, 0, "pendingcount");
    } else {
      $newlink = mysql_connect($row['dbserver'], $row['dbuser'], $row['dbpassword'], true);
      mysql_select_db($row['dbdatabase'], $newlink);
      $getapprovedcount = mysql_query("SELECT COUNT(*) as approvedcount FROM $row[dbtable] WHERE pending='0'");
      $approvedcount = mysql_result($getapprovedcount, 0, "approvedcount");
      $getpendingcount = mysql_query("SELECT COUNT(*) as pendingcount FROM $row[dbtable] WHERE pending='1'");
      $pendingcount = mysql_result($getpendingcount, 0, "pendingcount");
        mysql_close($newlink);
        include 'config.php';
    }
?>

<!-- customize the output -->
<tr>
<td><a href="<?=$url?>" target="_blank"><?=$title?>: <?=$subject?></a></td>
<td class="numberrow"><?=$approvedcount?></td>
<td><?=$pendingcount?></td>
</tr>
<!-- stop -->

<?php
}
?>
</table>


The code looks like my site as is but I commented to places to edit the output if you want a different look. If you need help getting it to look a certain way, just ask!

(Techie note to anyone who might understand: This was my first attempt at working with multiple mysql connections, and I couldn't stop 'mysql_close($newlink);' from closing all open connections instead of just $newlink. I think this is because the main connection Enth makes in the config file doesn't have a link identifier, but if anyone knows a better way please tell! I just solved it by re-including config.php. cool.gif )


--------------------
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
horrorshow
post May 2 2005, 08:01 AM
Post #6


Unregistered









ohmy.gif That's exactly what I was looking for, thank you so much!! wub.gif
Go to the top of the page
+Quote Post
Birgit
post May 2 2005, 08:29 AM
Post #7


Caffeinated
*****

Group: Loyal Members
Posts: 1,671
Joined: 2-December 04
From: Norway
Member No.: 1,849



Ah, great, Julie - gotta try this out once I get home this afternoon!


--------------------
IPB Image
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
ancalimesh
post Jun 5 2005, 04:17 PM
Post #8


Rank #4: Advanced
****

Group: Members
Posts: 150
Joined: 26-September 03
From: Germany, BY
Member No.: 434



You saved me again Julie. I was nearly trying to just put the config file of the fl and then the stats and so on. blink.gif
But, is there also a way to have complete approved and pending?


--------------------
- Julia
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
Monica
post Jun 14 2005, 09:19 PM
Post #9


Unregistered









This is great Julie, I used your code and I love it wub.gif
Go to the top of the page
+Quote Post
morbid romantic
post Jun 15 2005, 02:49 AM
Post #10


Rank #5: Obsessed
*****

Group: Members
Posts: 274
Joined: 12-May 03
From: Hampton, Virginia
Member No.: 33



*cries* I would love to use this, but I have my stuff on two domains (one flinx install, two domains) so I always get errors.


--------------------
"Let us aquaint ourselves with evil and it will not be long before we find it charming." - Marquis de Sade
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
Becky
post May 5 2007, 10:50 AM
Post #11


Rank #1: Newbie
*

Group: Members
Posts: 23
Joined: 23-April 07
Member No.: 8,355



I'm sorry to reply here I just wondered if maybe somebody could help me out with some errors I'm getting?

Warning: mysql_query() [function.mysql-query]: Access denied for user 'nobody'@'localhost' (using password: NO) in /home/beckykin/public_html/counts.php on line 62

Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in /home/beckykin/public_html/counts.php on line 62

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/beckykin/public_html/counts.php on line 63

:/
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
shirley_temple
post May 5 2007, 01:19 PM
Post #12


Rank #5: Obsessed
*****

Group: Loyal Members
Posts: 1,114
Joined: 4-August 03
From: canada
Member No.: 301



Please post your counts.php including the config.php


--------------------
Uma Fan [/b]- Uma fansite
Dita Von Teese Fan
Enth3 Affiliates error?
Please do a search before posting.
Please read the install / readme file in all scripts before posting.
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
Becky
post May 5 2007, 01:39 PM
Post #13


Rank #1: Newbie
*

Group: Members
Posts: 23
Joined: 23-April 07
Member No.: 8,355



counts.php page:

QUOTE
<?php
include '/home/beckykin/public_html/enth3/config.php';
?>

<table>
<!-- customize column headings -->
<tr>
<td>fanlisting</td>
<td>listed</td>
<td>pending</td></tr>
<!-- stop -->

<?php
$get_owned = mysql_query("SELECT * FROM $db_owned WHERE status='2' ORDER BY subject ASC");
while ($row = mysql_fetch_array($get_owned)) {
$title = $row['title'];
$subject = $row['subject'];
$url = $row['url'];

if ($row['dbserver'] == $db_server) {
$getapprovedcount = mysql_query("SELECT COUNT(*) as approvedcount FROM $row[dbtable] WHERE pending='0'");
$approvedcount = mysql_result($getapprovedcount, 0, "approvedcount");
$getpendingcount = mysql_query("SELECT COUNT(*) as pendingcount FROM $row[dbtable] WHERE pending='1'");
$pendingcount = mysql_result($getpendingcount, 0, "pendingcount");
} else {
$newlink = mysql_connect($row['dbserver'], $row['dbuser'], $row['dbpassword'], true);
mysql_select_db($row['dbdatabase'], $newlink);
$getapprovedcount = mysql_query("SELECT COUNT(*) as approvedcount FROM $row[dbtable] WHERE pending='0'");
$approvedcount = mysql_result($getapprovedcount, 0, "approvedcount");
$getpendingcount = mysql_query("SELECT COUNT(*) as pendingcount FROM $row[dbtable] WHERE pending='1'");
$pendingcount = mysql_result($getpendingcount, 0, "pendingcount");
mysql_close($newlink);
include 'config.php';
}
?>

<!-- customize the output -->
<tr>
<td><a href="<?=$url?>" target="_blank"><?=$title?>: <?=$subject?></a></td>
<td class="numberrow"><?=$approvedcount?></td>
<td><?=$pendingcount?></td>
</tr>
<!-- stop -->

<?php
}
?>
</table>


config file:

QUOTE
<?php
/******************************************************************************
DATABASE VARIABLES
These are the variables for your listing collective.
$db_server - database server, usually localhost
$db_user - username for your database
$db_password - password for your database
$db_database - actual database name
******************************************************************************/
$db_server = 'localhost';
$db_user = 'beckykin';
$db_password = '-----';
$db_database = 'beckykin_enth';


/******************************************************************************
DATABASE TABLE VARIABLES
These are the variables for your listing collective's tables. You can leave
these as they are unless you already use one of the default values as a
table name in your database previously.
$db_settings - table for Enth3 settings
$db_category - table for the categories
$db_joined - table for your joined listings
$db_owned - table for storing information about your owned listings
$db_affiliates - table for your *collective* affiliates
$db_emailtemplate - table for your email templates
$db_errorlog - table for your error logs (required even if not set)
******************************************************************************/
$db_settings = 'settings';
$db_category = 'category';
$db_joined = 'joined';
$db_owned = 'owned';
$db_affiliates = 'affiliates';
$db_emailtemplate = 'emailtemplate';
$db_errorlog = 'errorlog';



/******************************************************************************
SENDMAIL VARIABLE
This is the sendmail variable for your server. Please check with your
hosting provider for the correct value.
******************************************************************************/
$sendmail = '/usr/sbin/sendmail';



/******************************************************************************
DO NOT MODIFY BELOW THIS LINE!
******************************************************************************/
if( !defined( 'DATABASE_CONNECT_ERROR' ) )
define( 'DATABASE_CONNECT_ERROR', 'Cannot connect to the database. ' .
'Check your config file and try again. MySQL said: ' );
if( !defined( 'STANDARD_ERROR' ) )
define( 'STANDARD_ERROR', '<p class="error">Error executing query. ' .
'Please see the error logs.' );
?>
User is offlineProfile CardPM
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 

- Lo-Fi Version Time is now: 29th July 2010 - 11:39 AM