The following warnings occurred: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Warning [2] Undefined array key "avatartype" - Line: 783 - File: global.php PHP 8.1.31 (Linux)
|
Percentage calculation - Printable Version +- Form Tools (https://forums.formtools.org) +-- Forum: Form Tools (https://forums.formtools.org/forumdisplay.php?fid=1) +--- Forum: API (https://forums.formtools.org/forumdisplay.php?fid=17) +--- Thread: Percentage calculation (/showthread.php?tid=689) |
Percentage calculation - vizzaroo - May 7th, 2010 Hi Ben, I've been using form tools successfully now for several months and integrated perfectly for use. I have a question though if possible: When showing submission counts on a seperate page i.e <?php echo ft_api_show_submission_count(1, 235); ?> Shows a total of xxxx submissions <?php echo ft_api_show_submission_count(1, 236); ?> Shows a total of xxxx submissions Question: What I would like to do is get a percentage from those views. View 235 is the total submissions, view 236 is a filtered view of those submissions. So what I would like is to calculate a percentage of what view 236 is using php to show the end calculation on the page and update itself accordingly to each submission etc. Cheers for any advice or direction. RE: Percentage calculation - Ben - May 8th, 2010 Hey Vizzaroo, Sure, no problem! Try something like this: PHP Code: $count1 = ft_api_show_submission_count(1, 235); My math is pretty awful, but that should work. We use floor() rather than round() because the only ever time you want to see 100% is when the number of results in $count2 is identical to $count1. round() would round it up if it was .5 or higher. - Ben RE: Percentage calculation - vizzaroo - May 10th, 2010 Works Perfectly ! Thanks alot Ben. |