Page 1 of 1

Add comma to display counts over 3 digits?

Posted: Mon May 25, 2009 11:03 pm
by mickeyd
I would like to have a comma displayed on my website for counts over 999, for example 1,000 instead of 1000 or 15,050 instead of 15050.

I tried number_format in PHP but I'm not sure where I would add the code exactly.

Any help would be greatly appreciated!

Thanks!

Posted: Tue May 26, 2009 2:42 pm
by Klemen
Which script exactly are you using?

Posted: Tue May 26, 2009 3:47 pm
by mickeyd
PHP Click Counter (CCount)
Version: 1.2

Posted: Tue May 26, 2009 5:58 pm
by Klemen
Try opening display.php in Notepad and change

Code: Select all

echo "ccount_link[$id]=$count;\n";
to

Code: Select all

echo "ccount_link[$id]='".number_format($count)."';\n";
Upload the modified file, close all browser windows, open the page with counts again and see if it worked. If not try refreshing the page.

Posted: Tue May 26, 2009 6:40 pm
by DC
Klem just had an idea, why can't you add this as an option to the script so it can then be chosen if the user likes like so...

//In settings ...

/* Count with format 1 = YES, 0 = NO examp: 1,345 or 1345 */
$settings['count_formated']=1;


In display ...

if ($settings['count_formated']){
echo "ccount_link[$id]='".number_format($count)."';\n";
}else{
echo "ccount_link[$id]=$count;\n";
}


Just an idea to simplify this for others maybe wanting auto format ...

DC

Posted: Tue May 26, 2009 9:35 pm
by mickeyd
Hey Klemen, it worked! Thanks so much!

Also, as DC mentioned, it might be a nice addition to the next version of the script.

:D

Re: Add comma to display counts over 3 digits?

Posted: Thu May 31, 2012 10:28 am
by Pilo
This solution worked for me too. I think 10,171 is far better than 10171.

It would be nice to see this as a setting in a future version.

Thanks.