Page 1 of 1

users in total

PostPosted: 10:38am, Sun 09 Feb, 2014
by mobilenetsolution
Hi, quick Question

PHPList Version 2.10.13
I want to show the users in total on my Front Page as Info for my Visitors.
How can i do this?

Thanks for any help

Re: users in total

PostPosted: 11:11am, Sun 09 Feb, 2014
by Dragonrider
You'll need to add a mixture of php and mysql to get this to work.

The following code should work on version 2 and 3 without any amendments.

The only change you would need to do is change phplist in line 4 to match your installation directory.

Other than that, the code accesses your config.php file, obtains the database settings, then does a count on the _user_user table which is where the number of users are stored, and displays the same.
Code: Select all

//  Get database settings from config.php file
require_once dirname(__FILE__) .'/phplist/config/config.php';
$con = mysql_connect($database_host ,$database_user,$database_password);

// Check that settings correct and can connect to database
if (!$con) {
  die('Could not connect: ' . mysql_error());

mysql_select_db($database_name, $con);

// Access phplist_user_user table or whatever table prefix you set in config file
$table = $table_prefix."user_user";
$result = mysql_query("select count(1) FROM $table");
$row = mysql_fetch_array($result);

$total = $row[0];

//Display count of users
echo "Total users: " . $total;

//Exit database tidily


It can be used in pretty much any webpage and all anyone can see, if they look at the source code of the page, is the result Total users: ###

Hope that helps.

Re: users in total

PostPosted: 7:37pm, Sun 09 Feb, 2014
by mobilenetsolution
Thanks a lot, was helping me absolut fine, much appreciated