Add comma to display counts over 3 digits?

Post your Click counter digestion problems here
Post Reply
mickeyd
Posts: 3
Joined: Mon May 25, 2009 11:00 pm

Add comma to display counts over 3 digits?

Post 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!
Klemen
Site Admin
Posts: 10116
Joined: Fri Feb 11, 2005 4:04 pm

Post by Klemen »

Which script exactly are you using?
Klemen, creator of HESK and PHPJunkyardWas this helpful? You can buy me a drink here Image

Image You should follow me on Twitter here

Help desk software | Cloud help desk | Guestbook | Link manager | Click counter | more PHP Scripts ...

Also browse for php hosting companies, read php books, find php resources and use webmaster tools
mickeyd
Posts: 3
Joined: Mon May 25, 2009 11:00 pm

Post by mickeyd »

PHP Click Counter (CCount)
Version: 1.2
Klemen
Site Admin
Posts: 10116
Joined: Fri Feb 11, 2005 4:04 pm

Post 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.
Klemen, creator of HESK and PHPJunkyardWas this helpful? You can buy me a drink here Image

Image You should follow me on Twitter here

Help desk software | Cloud help desk | Guestbook | Link manager | Click counter | more PHP Scripts ...

Also browse for php hosting companies, read php books, find php resources and use webmaster tools
DC
Posts: 138
Joined: Sun Dec 09, 2007 9:28 am

Post 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
To Code Or Not To Code That Is The Question?

Was my post of any help to you? if so please do [url=http://www.clickcraft.net/slice_donations.php][b]Buy Me A Slice[/b][/url] ...
mickeyd
Posts: 3
Joined: Mon May 25, 2009 11:00 pm

Post 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
Pilo
Posts: 6
Joined: Sun Jul 26, 2009 5:20 pm

Re: Add comma to display counts over 3 digits?

Post 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.
Post Reply