Author Topic: Little request  (Read 8387 times)

0 Members and 1 Guest are viewing this topic.

Offline stdio

  • Newbie
  • *
  • Posts: 41
    • View Profile
Little request
« on: April 01, 2010, 04:07:18 PM »
Hello,

I am displaying my stats on my website. I wish to display my stats in this format: (example: Hits: xxx,xxx and not Hits: xxxxxx). You see, there is a comma in the first version. I know it is possible because I saw it on a website but sadly I don't know how to do it. Can anyone help please?

Thank you!

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: Little request
« Reply #1 on: April 02, 2010, 01:03:31 AM »
In includes/functions.php find:
    "image_hits" => $image_row['image_hits'],

Replace with:
    "image_hits" => number_format($image_row['image_hits']),
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline stdio

  • Newbie
  • *
  • Posts: 41
    • View Profile
Re: Little request
« Reply #2 on: April 02, 2010, 01:26:41 AM »
Hi V@no!

Thanks for your reply. I did as you said but nothing is changed. I think it's because I am using the mini-stats mod and the stats are displayed from the stats.php file. I think something needs to be changed in this file:

Code: [Select]
//-----------------------------------------------------
//--- Hits --------------------------------------------
//-----------------------------------------------------
        $sql = "SELECT SUM(image_hits) AS sum
          FROM ".IMAGES_TABLE;
  $row = $site_db->query_firstrow($sql);

  $sum = (isset($row['sum'])) ? $row['sum'] : 0;
  $total_hits = "".$lang['total_hits']."<B> ".$row['sum']."</B>\n";

  $site_template->register_vars("total_hits", $total_hits);
unset($total_hits);

Please help.

Thank you very much!

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: Little request
« Reply #3 on: April 02, 2010, 02:02:25 AM »
  $total_hits "".$lang['total_hits']."<B> ".number_format($row['sum'])."</B>\n";
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline stdio

  • Newbie
  • *
  • Posts: 41
    • View Profile
Re: Little request
« Reply #4 on: April 02, 2010, 02:18:17 AM »
Thank you very much! Works perfectly! :)

Happy Easter!

Offline stdio

  • Newbie
  • *
  • Posts: 41
    • View Profile
Re: Little request
« Reply #5 on: April 15, 2010, 11:32:48 AM »
Hi V@no!

Can you help me with this issue for another "version" of stats?

Code: [Select]
    $sql = "SELECT COUNT(*) as all_total_users
          FROM ".USERS_TABLE."
                  WHERE user_id <> ".GUEST;
  $row = $site_db->query_firstrow($sql);
  $all_total_users = $row['all_total_users'];
  $lang_all_total_users = $lang['all_total_users'];

  $site_template->register_vars("all_total_users", $all_total_users);
  $site_template->register_vars("lang_all_total_users", $lang_all_total_users);
  unset($all_total_users);
  unset($lang_all_total_users);
I want the , in this code again. I tried to modify it but I always get a Parse error. Please help.

Thank you!

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: Little request
« Reply #6 on: April 15, 2010, 02:06:37 PM »
  $site_template->register_vars("all_total_users"number_format($all_total_users));

should do it.
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline stdio

  • Newbie
  • *
  • Posts: 41
    • View Profile
Re: Little request
« Reply #7 on: April 15, 2010, 02:40:48 PM »
Thank you very much! Works wonders! :)

Have a great day!

I have like 2-3 versions of different stats (total hits, total members, etc). Could you advise me how to change this code:
Code: [Select]
       $sql = "SELECT SUM(image_hits) AS sum
          FROM ".IMAGES_TABLE;
  $row = $site_db->query_firstrow($sql);

  $sum = (isset($row['sum'])) ? $row['sum'] : 0;
$total_hits = "".$lang['total_hits']."<B> ".number_format($row['sum'])."</B>\n";

  $site_template->register_vars("total_hits", $total_hits);
unset($total_hits);
into a more friendly one like:

Code: [Select]
   $sql = "SELECT COUNT(*) as all_total_users
          FROM ".USERS_TABLE."
                  WHERE user_id <> ".GUEST;
  $row = $site_db->query_firstrow($sql);
  $all_total_users = $row['all_total_users'];
  $lang_all_total_users = $lang['all_total_users'];

  $site_template->register_vars("all_total_users", number_format($all_total_users));
  $site_template->register_vars("lang_all_total_users", $lang_all_total_users);
  unset($all_total_users);
  unset($lang_all_total_users);

As you see, total hits is very different than total users. I want to have all stats code the same way. I like order. Hope you understand.

Thank you very much for your time!
« Last Edit: April 15, 2010, 02:52:45 PM by stdio »

Offline stdio

  • Newbie
  • *
  • Posts: 41
    • View Profile
Re: Little request
« Reply #8 on: April 16, 2010, 09:45:55 PM »
Hi V@no!

I am writing again because you probably didn't notice that I updated my previous post. Can you help in regards to that?

Thank you!

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: Little request
« Reply #9 on: April 17, 2010, 02:08:57 AM »
Sorry, I don't understand your question...
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline stdio

  • Newbie
  • *
  • Posts: 41
    • View Profile
Re: Little request
« Reply #10 on: April 19, 2010, 12:55:01 AM »
Dear V@no,

I want to turn this version:

Code: [Select]
        $sql = "SELECT SUM(image_hits) AS sum
          FROM ".IMAGES_TABLE;
  $row = $site_db->query_firstrow($sql);

  $sum = (isset($row['sum'])) ? $row['sum'] : 0;
$total_hits = "".$lang['total_hits']."<B> ".number_format($row['sum'])."</B>\n";

  $site_template->register_vars("total_hits", $total_hits);
unset($total_hits);
into this version:

Code: [Select]
    $sql = "SELECT COUNT(*) as all_total_users
          FROM ".USERS_TABLE."
                  WHERE user_id <> ".GUEST;
  $row = $site_db->query_firstrow($sql);
  $all_total_users = $row['all_total_users'];
  $lang_all_total_users = $lang['all_total_users'];

  $site_template->register_vars("all_total_users", number_format($all_total_users));
  $site_template->register_vars("lang_all_total_users", $lang_all_total_users);
  unset($all_total_users);
  unset($lang_all_total_users);
.

You understand now? If not I will try to explain better. Basically I am using 2 versions of stats, collected from different threads but both do the same thing.