The following warnings occurred:
Warning [2] Undefined array key "avatartype" - Line: 783 - File: global.php PHP 8.1.31 (Linux)
File Line Function
/global.php 783 errorHandler->error
/printthread.php 16 require_once
Warning [2] Undefined array key "avatartype" - Line: 783 - File: global.php PHP 8.1.31 (Linux)
File Line Function
/global.php 783 errorHandler->error
/printthread.php 16 require_once
Warning [2] Undefined variable $newpmmsg - Line: 40 - File: global.php(841) : eval()'d code PHP 8.1.31 (Linux)
File Line Function
/global.php(841) : eval()'d code 40 errorHandler->error
/global.php 841 eval
/printthread.php 16 require_once
Warning [2] Undefined array key "style" - Line: 909 - File: global.php PHP 8.1.31 (Linux)
File Line Function
/global.php 909 errorHandler->error
/printthread.php 16 require_once
Warning [2] Undefined property: MyLanguage::$lang_select_default - Line: 5024 - File: inc/functions.php PHP 8.1.31 (Linux)
File Line Function
/inc/functions.php 5024 errorHandler->error
/global.php 909 build_theme_select
/printthread.php 16 require_once
Warning [2] Undefined array key "additionalgroups" - Line: 7162 - File: inc/functions.php PHP 8.1.31 (Linux)
File Line Function
/inc/functions.php 7162 errorHandler->error
/inc/functions.php 5044 is_member
/global.php 909 build_theme_select
/printthread.php 16 require_once
Warning [2] Undefined array key 1 - Line: 1415 - File: inc/functions.php PHP 8.1.31 (Linux)
File Line Function
/inc/functions.php 1415 errorHandler->error
/inc/functions.php 1370 fetch_forum_permissions
/printthread.php 76 forum_permissions
Warning [2] Undefined array key "showimages" - Line: 160 - File: printthread.php PHP 8.1.31 (Linux)
File Line Function
/printthread.php 160 errorHandler->error
Warning [2] Undefined array key "showvideos" - Line: 165 - File: printthread.php PHP 8.1.31 (Linux)
File Line Function
/printthread.php 165 errorHandler->error
Warning [2] Undefined array key "showimages" - Line: 160 - File: printthread.php PHP 8.1.31 (Linux)
File Line Function
/printthread.php 160 errorHandler->error
Warning [2] Undefined array key "showvideos" - Line: 165 - File: printthread.php PHP 8.1.31 (Linux)
File Line Function
/printthread.php 165 errorHandler->error
Warning [2] Undefined array key "showimages" - Line: 160 - File: printthread.php PHP 8.1.31 (Linux)
File Line Function
/printthread.php 160 errorHandler->error
Warning [2] Undefined array key "showvideos" - Line: 165 - File: printthread.php PHP 8.1.31 (Linux)
File Line Function
/printthread.php 165 errorHandler->error



Form Tools
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(1235);
$count2 ft_api_show_submission_count(1236);

// now $count1 and $count2 contain the number of results in those 
// two Views. Assuming $count1 will always contain more than $count2:
$percentage floor(($count2 $count1) * 100);

// display it!
echo $percentage

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.