Gossamer Forum
Quote Reply
Calculating percentage
Hi!

Anybody know how to calculate percentages with globals?

Example:

In my directory there is a number of links which link back to my site and I need a percentage ...

Link Back out of Total Links (something like this) Blush



Thanks in advance!

Last edited by:

Payooo: Dec 3, 2002, 6:52 AM
Quote Reply
Re: [Payooo] Calculating percentage In reply to
Not sure exactly...but you would need to do something like;

1) Do a count() from lsql_Links
2) Do another count, but only where the Recip link is set....
3) Do the basic percentage calculations (total / 100 * recip links)

Without knowing how you hold these values in your database, its pretty hard to write a global for ya Wink

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Payooo] Calculating percentage In reply to
Code:
my $total = $DB->table('Links')->count;
my $back = $DB->table('Links')->count({ LinkBack => 'Yes' });
my $pcnt = sprintf("%.0f", (($back / $total) * 100));

return $pcnt
Quote Reply
Re: [Andy] Calculating percentage In reply to
Thanks Andy.

Each site which link back to mine is set to Yes. (LinkBack=Yes)

Maybe that helps.
Quote Reply
Re: [Payooo] Calculating percentage In reply to
Should be able to use Pauls global above then... Tongue I'm not sure how he worked out the field name you were using though :/

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] Calculating percentage In reply to
Wooow! Smile



Working great!

Thank you both for this one ...





>>>

I'm not sure how he worked out the field name you were using though :/

>>>

Maybe he is a mind reader Wink (now I'm scared)
Quote Reply
Re: [Payooo] Calculating percentage In reply to
Quote:
Thank you both for this one ...

Heh, what did Andy do?...it was all my hard work Laugh
Quote Reply
Re: [Paul] Calculating percentage In reply to
I pointed him in the right direction Smile If I had known what his field name was, then I probably would have come up with a global to use too ;)

LOL....I think Paul must be on one of his natural highs today...he can't stop having a go/joking at me :(

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Paul] Calculating percentage In reply to
Yup, you are right! Wink

Thanks Paul.
Quote Reply
Re: [Andy] Calculating percentage In reply to
You could have made up a field name like I did and then you could have received congratulations for being psychic Tongue
Quote Reply
Re: [Payooo] Calculating percentage In reply to
Go on then Payoo...I think Paul has deserved his Kiss from Frankenstein now Wink

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Paul] Calculating percentage In reply to
Paul, you were close. The field name is Link_Back.

Exercise, exercise ... Wink

Anyway ... I KISS YOU!
Quote Reply
Re: [Payooo] Calculating percentage In reply to
Ah well you see I actually read your mind whilst you were posting....

Quote:
Each site which link back to mine is set to Yes. (LinkBack=Yes)

You are just trying to diss my psychic powers now by pretending I was wrong Smile
Quote Reply
Re: [Paul] Calculating percentage In reply to
My fault!

Too lazy to check the correct name. Wink

But that only shows that you are doing great with mind reading.Tongue