Author Topic: [Mod] More Statistics for your visitors  (Read 200343 times)

0 Members and 1 Guest are viewing this topic.

Offline vipersgarden

  • Jr. Member
  • **
  • Posts: 69
    • View Profile
Re: [Mod] More Statistics for your visitors
« Reply #135 on: September 19, 2007, 09:04:16 PM »
Hello,

may you help me with a small problem (I think so).
I´m no PHP Guru !!!

Within the stats.php
I´ve tried to include a mathematic function.
Dividing {total_votes by {total_hits}.
So I would get the percentage of votes from visited images!

I´ve tried the following, but get parse errors:

Code: [Select]
//------------------------------------------------------
//----- Berechnung ---------------------------------
//--------------------------------------------------

bcdiv($total_votes, $total_hits, 3)
 $bcdiv = "".$lang['bcdiv']."<B> ".$bcdiv."</B>\n";
 
 $site_template->register_vars("bcdiv", $bcdiv);
unset($bcdiv);

I´m really no Guru, so someone may help please

regardes
Mario
Mario Schweiger


Offline thunderstrike

  • 4images Guru
  • *******
  • Posts: 2.327
    • View Profile
Re: [Mod] More Statistics for your visitors
« Reply #136 on: September 19, 2007, 09:08:47 PM »
Ok so where bcdiv come from ?
8 steps need when ask question -

- PHP version (ACP - > phpinfo())
- mySQL version (ACP - > phpinfo())
- 4images version
- Post screenshot / URL
- Post code in BB Code (no need full file for code) or post attach file
- It doesn't work. What is say - what is do for no work
- Install MOD ? If so - please say (troubleshooting)
- Read FAQ ? Install Bug fixes ?

Offline vipersgarden

  • Jr. Member
  • **
  • Posts: 69
    • View Profile
Re: [Mod] More Statistics for your visitors
« Reply #137 on: September 19, 2007, 09:14:33 PM »
bcdiv I´ve found in a php manual:
it is the math function to divide two numbers

Code: [Select]
string bcdiv ( string left_operand, string right_operand [, int scale] )
Code: [Select]
<?php

echo bcdiv('105''6.55957'3);  // 16.007

?>

that´s all I found

thanks mario
Mario Schweiger


Offline thunderstrike

  • 4images Guru
  • *******
  • Posts: 2.327
    • View Profile
Re: [Mod] More Statistics for your visitors
« Reply #138 on: September 19, 2007, 09:37:14 PM »
Better - use two SQL query for SELECT SUM . See example from admin/home.php file for see what is. ;)
8 steps need when ask question -

- PHP version (ACP - > phpinfo())
- mySQL version (ACP - > phpinfo())
- 4images version
- Post screenshot / URL
- Post code in BB Code (no need full file for code) or post attach file
- It doesn't work. What is say - what is do for no work
- Install MOD ? If so - please say (troubleshooting)
- Read FAQ ? Install Bug fixes ?

Offline vipersgarden

  • Jr. Member
  • **
  • Posts: 69
    • View Profile
Re: [Mod] More Statistics for your visitors
« Reply #139 on: September 19, 2007, 09:57:34 PM »
Dear thunderstrike,

1) please may you tell me a bit more exact, what you mean?

2) I´ve got it (a bit)

Code: [Select]
//------------------------------------------------------
//----- Berechnung ---------------------------------
//--------------------------------------------------

echo bcdiv('total_votes', 'total_hits', 3);

but got the following (site is working anyway):
Code: [Select]
Warning: bcdiv(): Division by zero in /home/www/web386/html/4images/includes/stats.php on line 72

Why ???


thx
Mario
Mario Schweiger


Offline thunderstrike

  • 4images Guru
  • *******
  • Posts: 2.327
    • View Profile
Re: [Mod] More Statistics for your visitors
« Reply #140 on: September 19, 2007, 10:12:35 PM »
Change:

Quote
bcdiv($total_votes, $total_hits, 3);
$bcdiv = "".$lang['bcdiv']."<B> ".$bcdiv."</B>\n";

for:

Code: [Select]
$get_totals = $total_votes / $total_hits;
if ($get_totals > 0) {
$bcdiv = $lang['bcdiv']."<B> ".$get_totals."</B>\n";
} else {
$bcdiv = $lang['bcdiv']."<B> 0 </B>\n";
}
8 steps need when ask question -

- PHP version (ACP - > phpinfo())
- mySQL version (ACP - > phpinfo())
- 4images version
- Post screenshot / URL
- Post code in BB Code (no need full file for code) or post attach file
- It doesn't work. What is say - what is do for no work
- Install MOD ? If so - please say (troubleshooting)
- Read FAQ ? Install Bug fixes ?

Offline vipersgarden

  • Jr. Member
  • **
  • Posts: 69
    • View Profile
Re: [Mod] More Statistics for your visitors
« Reply #141 on: September 19, 2007, 10:24:08 PM »
Dear Thunderstrike,

the same: division by zero!

Code: [Select]
//------------------------------------------------------
//----- Berechnung ---------------------------------
//--------------------------------------------------
$get_totals = $total_votes / $total_hits;
if ($get_totals > 0) {
$bcdiv = $lang['bcdiv']."<B> ".$get_totals."</B>\n";
} else {
$bcdiv = $lang['bcdiv']."<B> 0 </B>\n";
}

Maybe (I don´t know) because of this:

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

  $sum = (isset($row['sum'])) ? $row['sum'] : 0;
  $total_votes = "".$lang['total_votes']."<B> ".$row['sum']."</B>\n";
 
  $site_template->register_vars("total_votes", $total_votes);
unset($total_votes);
last line!

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);
last line too
Mario Schweiger


Offline thunderstrike

  • 4images Guru
  • *******
  • Posts: 2.327
    • View Profile
Re: [Mod] More Statistics for your visitors
« Reply #142 on: September 19, 2007, 10:37:16 PM »
Ah ! ok so

find:

Quote
unset($total_votes);

move after this:

Quote
unset($total_hits);

(Keep same change of my post before)
8 steps need when ask question -

- PHP version (ACP - > phpinfo())
- mySQL version (ACP - > phpinfo())
- 4images version
- Post screenshot / URL
- Post code in BB Code (no need full file for code) or post attach file
- It doesn't work. What is say - what is do for no work
- Install MOD ? If so - please say (troubleshooting)
- Read FAQ ? Install Bug fixes ?

Offline vipersgarden

  • Jr. Member
  • **
  • Posts: 69
    • View Profile
Re: [Mod] More Statistics for your visitors
« Reply #143 on: September 19, 2007, 11:00:39 PM »
just the same: division by zero!

Only an idea:
how to get "new" variables out of "total_hits" and "total_votes" - inside the functions?

mario
Mario Schweiger


Offline thunderstrike

  • 4images Guru
  • *******
  • Posts: 2.327
    • View Profile
Re: [Mod] More Statistics for your visitors
« Reply #144 on: September 19, 2007, 11:39:52 PM »
8 steps need when ask question -

- PHP version (ACP - > phpinfo())
- mySQL version (ACP - > phpinfo())
- 4images version
- Post screenshot / URL
- Post code in BB Code (no need full file for code) or post attach file
- It doesn't work. What is say - what is do for no work
- Install MOD ? If so - please say (troubleshooting)
- Read FAQ ? Install Bug fixes ?

Offline vipersgarden

  • Jr. Member
  • **
  • Posts: 69
    • View Profile
Re: [Mod] More Statistics for your visitors
« Reply #145 on: September 20, 2007, 03:35:53 PM »
I´ve got it to compute !

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

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

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

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

  $treffer = $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);

and
Code: [Select]
echo bcdiv ($bewert, $treffer, 4);
I can see the correct result on top of the screen.

But when I use this (thunderstrike) code, nothing happens!
Code: [Select]
$get_totals = bcdiv ($bewert, $treffer, 4);
if ($get_totals > 0) {
$bcdiv = $lang['bcdiv']."<B> ".$get_totals."</B>\n";
} else {
$bcdiv = $lang['bcdiv']."<B> 0 </B>\n";
}
$site_template->register_vars("get_totals", $get_totals);

I also have my "bcdiv" in the lang/main.php file
Code: [Select]
$lang['bcdiv'] = "Entspricht Prozent:";
What´s wrong in the last part of the script?

thx Mario
Mario Schweiger


Offline vipersgarden

  • Jr. Member
  • **
  • Posts: 69
    • View Profile
Re: [Mod] More Statistics for your visitors
« Reply #146 on: September 20, 2007, 04:50:17 PM »
I´ve got it !

This was learning by doing!

And it is sooooo easy!- when you know it!

Code: [Select]
//------------------------------------------------------
//----- Berechnung ---------------------------------
//--------------------------------------------------

$get_totals = bcdiv ($bewert, $treffer, 4);
$ergebnis = $get_totals*100;
$site_template->register_vars("ergebnis", $ergebnis);

Result:



But anyway,
thanks for all help!!

Mario
Mario Schweiger


Offline son_gokou

  • Full Member
  • ***
  • Posts: 199
    • View Profile
More Registered Users
« Reply #147 on: November 18, 2008, 04:15:03 PM »
Hello.

I've started a gallery. It is possible to increment registered users (of course not regiistering one, and another, and another...)? In others words, I don't want to appear 0 registered users. How can I make it appear 100 registered user per example?

Best regards

Offline Nicky

  • Administrator
  • 4images Guru
  • *****
  • Posts: 3.195
    • View Profile
Re: More Registered Users
« Reply #148 on: November 18, 2008, 06:10:12 PM »
hmmm...

i didn't got this....

where should this be visible?

this one:
Quote
There are currently 2 registered user(s) (1 among them invisible) and 0 guest(s) online.
?
cheers
Nicky
Your first three "must do" before you ask a question ! (© by V@no)
- please read the Forum Rules ...
- please study the FAQ ...
- please try to Search for your answer ...

nicky.net 4 4images
Signature stolen from mawenzi

Offline son_gokou

  • Full Member
  • ***
  • Posts: 199
    • View Profile
Re: More Registered Users
« Reply #149 on: November 18, 2008, 06:17:37 PM »
That was my fault... hard to explain.

No... here:
Registered Members: 0