Author Topic: [MOD] - Statistics for total users by gender  (Read 4920 times)

0 Members and 1 Guest are viewing this topic.

Offline Stoleti

  • Hero Member
  • *****
  • Posts: 574
    • View Profile
[MOD] - Statistics for total users by gender
« on: August 30, 2006, 10:04:03 PM »
Well i've make it for my website and i've decided share it , its my first tiny mod !!

BACKUP ALL FILES BEFORE !!!

This mod requires:

[MOD] Select country and gender with gif when register => http://www.4homepages.de/forum/index.php?topic=7385.0


First create a new php file "gender_stats.php" and upload to 4images/includes/

Quote
<?PHP
if (!defined('ROOT_PATH')) {
  die("Security violation");
}
//-----------------------------------------------------
//--- Show number of Girls ----------------------------
//-----------------------------------------------------
  $sql = "SELECT COUNT(*) as users
         FROM ".USERS_TABLE."
         WHERE user_id >= '".GUEST."' AND user_gender = 'Female'";
 $row = $site_db->query_firstrow($sql);

 $total_girls = "".$lang['users_girls']." ".$row['users']."\n";
 
 $site_template->register_vars("total_girls", $total_girls);
unset($total_girls);
//-----------------------------------------------------
//--- Show number of Boys ----------------------------
//-----------------------------------------------------
  $sql = "SELECT COUNT(*) as users
         FROM ".USERS_TABLE."
         WHERE user_id >= '".GUEST."' AND user_gender = 'Male'";
 $row = $site_db->query_firstrow($sql);

 $total_boys = "".$lang['users_boys']." ".$row['users']."\n";
 
 $site_template->register_vars("total_boys", $total_boys);
unset($total_boys);
//-----------------------------------------------------
//--- Show number of Bisexual ----------------------------
//-----------------------------------------------------
  $sql = "SELECT COUNT(*) as users
         FROM ".USERS_TABLE."
         WHERE user_id >= '".GUEST."' AND user_gender = 'Bisexual'";
 $row = $site_db->query_firstrow($sql);

 $total_bisexual = "".$lang['users_bisexual']." ".$row['users']."\n";
 
 $site_template->register_vars("total_bisexual", $total_bisexual);
unset($total_bisexual);
?>

Open Main.php and add before ?>

Quote
$lang['users_boys'] = "Total Boys:";
$lang['users_girls'] = "Total Girls:";
$lang['users_bisexual'] = "Total Bisexual:";

Now at your index.php find:

Quote
require(ROOT_PATH.'includes/sessions.php');

Add after:

Quote
include(ROOT_PATH.'includes/gender_stats.php');

After you just need added the tags at your html template:

{total_bisexual}
{total_boys}
{total_girls}

Remenber i've test it at my own gallery using 1.7.1 , so use it at your own risk !!  :wink:

« Last Edit: August 31, 2006, 05:22:40 PM by Stoleti »

Offline 4ella

  • Jr. Member
  • **
  • Posts: 90
    • View Profile
    • http://www.dancersrecruit.com/pictures/
Re: [MOD] - Statistics for total users by gender
« Reply #1 on: May 02, 2009, 04:10:47 AM »
nice little code , Thanks Stoleti , but maybe after many years it didn't worked in 1.7.6 or
I dont know if I'm lucky but i changed bisexual = b  , man=m   ,female =f and it works now .
so this is the code working good in my 1.7.6 now


Quote
<?PHP
if (!defined('ROOT_PATH')) {
  die("Security violation");
}
//-----------------------------------------------------
//--- Show number of Girls ----------------------------
//-----------------------------------------------------
  $sql = "SELECT COUNT(*) as users
         FROM ".USERS_TABLE."
         WHERE user_id >= '".GUEST."' AND user_gender = 'f'";
 $row = $site_db->query_firstrow($sql);

 $total_girls = "".$lang['users_girls']." ".$row['users']."\n";
 
 $site_template->register_vars("total_girls", $total_girls);
unset($total_girls);
//-----------------------------------------------------
//--- Show number of Boys ----------------------------
//-----------------------------------------------------
  $sql = "SELECT COUNT(*) as users
         FROM ".USERS_TABLE."
         WHERE user_id >= '".GUEST."' AND user_gender = 'm'";
 $row = $site_db->query_firstrow($sql);

 $total_boys = "".$lang['users_boys']." ".$row['users']."\n";
 
 $site_template->register_vars("total_boys", $total_boys);
unset($total_boys);
//-----------------------------------------------------
//--- Show number of Bisexual ----------------------------
//-----------------------------------------------------
  $sql = "SELECT COUNT(*) as users
         FROM ".USERS_TABLE."
         WHERE user_id >= '".GUEST."' AND user_gender = 'b'";
 $row = $site_db->query_firstrow($sql);

 $total_bisexual = "".$lang['users_bisexual']." ".$row['users']."\n";
 
 $site_template->register_vars("total_bisexual", $total_bisexual);
unset($total_bisexual);
?>

http://www.dancersrecruit.com/pictures/
4IMAGES 1.7.6 version/default theme
Apache version   2.2.11 (Unix)
PHP version   5.2.9
MySQL version   5.0.75-community-log
Architecture   x86_64
Operating system   Linux

Offline alfieflor

  • Pre-Newbie
  • Posts: 1
  • I'm banned for spam
    • View Profile
Re: [MOD] - Statistics for total users by gender
« Reply #2 on: August 26, 2009, 10:12:34 AM »
        I hope this will be in function in the next year.


_________________
Adt security  (link altered)
« Last Edit: August 26, 2009, 02:37:39 PM by V@no »