How many gallery members? How many gallery members?
 

News:

cpg1.5.48 Security release - upgrade mandatory!
The Coppermine development team is releasing a security update for Coppermine in order to counter a recently discovered vulnerability. It is important that all users who run version cpg1.5.46 or older update to this latest version as soon as possible.
[more]

Main Menu

How many gallery members?

Started by hama, March 08, 2005, 08:25:35 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

hama


Hi

I would like to make visible (on my startpage, not on the startpage of the gallery) how many users are registered in my gallery.

I did it with "How many pictures" and with "How many hits" but with "Registered users" I can't find the solution.

Solution for "Pictures":


<?php
// gallery_pics
$gallery_pics implode(''$_gallery->fetch_first('SELECT COUNT(*) FROM cpg132_pictures AS p, cpg132_albums AS a WHERE p.aid = a.aid '));
?>



Solution for "Hits":


<?php
// gallery hits
$gallery_hits implode(''$_gallery->fetch_first('SELECT SUM(`hits`) FROM cpg132_pictures AS p, cpg132_albums AS a WHERE p.aid = a.aid '));
?>



Solution for "Registered users":


<?php
// gallery members
$gallery_members I don't find the solution.;
?>



Thanks for a bit help.  :)

hama

Get up, stand up, stand up for your rights! - Get up, stand up, don't give up the fight!

Joachim Müller

The code $_gallery->fetch_first is neither PHP standards nor does it come with coppermine: you're either refering to some mod you applied, or you have created your own function. In both cases, we don't no what you did, so you will have to give more details (and maybe post a reference to the mod you're using). For an unbridged coppermine install, the query to show the number of registered users would look like this: SELECT COUNT(*) FROM cpg132_users WHERE  user_active = 'YES'afaik.

Joachim

nol33t

Quote from: GauGau on March 09, 2005, 10:07:35 AM
SELECT COUNT(*) FROM cpg132_users WHERE  user_active = 'YES'

[tips of the day]
a good habit is to put the primary key only in the count ( so "count(user_id)" ) --> real difference in time execution when you deal with big tables
[/tips of the day]
;)

hama


@GauGau

It's an unbridged coppermine install and not a hack or a mod. For sure it's not PHP standard, it's try and error, learning by doing, and I'm happy that it works ...  :)

This one is in the head.php of my website (not gallery):


// new Gallery DB
$_gallery = new db($_cfg['DB_SERVER'], $_cfg['DB_GALLERY_USER'], $_cfg['DB_GALLERY_PASS'], $_cfg['DB_GALLERY_NAME']);
   
// gallery_pics
$gallery_pics = implode('', $_gallery->fetch_first('SELECT COUNT(*) FROM cpg132_pictures AS p, cpg132_albums AS a WHERE p.aid = a.aid '));
   
// gallery hits
$gallery_hits = implode('', $_gallery->fetch_first('SELECT SUM(`hits`) FROM cpg132_pictures AS p, cpg132_albums AS a WHERE p.aid = a.aid '));


And with this one in the left_login.tpl I get the result on the startpage of my website (for example www.orst.ch after login with test test).


   <li><a href="http://www.orst.ch/copper/index.php">Gallery-Fotos</a> ($gallery_pics)</li>
   <li><a href="http://www.orst.ch/copper/index.php">Gallery-Views</a> ($gallery_hits)</li>


Now I'll try to build in how many users are registered in the gallery (thanks for your idea, I'll try it out).

The difference between your idea and the idea of "nol33t" I don't understand.

My website is builded around a forum (it's a very good one) but there is no gallery bridge for this forum, so I think my solution is not so bad for the moment (except the problem that everybody has to make two registrations/logins, one for the website (including the forum) and another one for the gallery).

If it would be very easy to build in automaticly all the forum users into the gallery, so that every website user after his login is also logged in into the gallery, I'm open for this solution.  ;)

hama
Get up, stand up, stand up for your rights! - Get up, stand up, don't give up the fight!

nol33t

Quote from: hama on March 09, 2005, 04:55:31 PM
The difference between your idea and the idea of "nol33t" I don't understand.

you weren't talkin' to me but since you seem to want to understand: this is the same idea. but the day you'll have 200 000 users, count(user_id) will be faster than count(*)

you probably won't ever have that many users but as i said: it's just a good habit not to count(*)

-matt-

hama


@ -matt- !

200 000 users ... wow ... not today and not tomorrow ...  :o

If I understand you correctly I better change the code from

SELECT COUNT(*)  to  SELECT COUNT(user_id).

Thanks and have a good time

hama

Get up, stand up, stand up for your rights! - Get up, stand up, don't give up the fight!