/[health_html]/inc/pgBMI.php
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Contents of /inc/pgBMI.php

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (show annotations)
Thu Oct 4 14:59:35 2001 UTC (17 years, 6 months ago) by ravilov
Branch: MAIN
CVS Tags: HEAD
Changes since 1.1: +1 -1 lines
Added the archive. Some more bug fixes.

1 <?php
2 $onload .= "document.forms[1].elements[0].focus();";
3 $result_m = array(
4 array("l" => -1, "h" => 20.7),
5 array("l" => 20.7, "h" => 26.4),
6 array("l" => 26.5, "h" => 27.8),
7 array("l" => 27.9, "h" => 31.1),
8 array("l" => 31.2, "h" => 45.4),
9 array("l" => 45.4, "h" => -1),
10 );
11 $result_z = array(
12 array("l" => -1, "h" => 19.1),
13 array("l" => 19.1, "h" => 25.8),
14 array("l" => 25.9, "h" => 27.3),
15 array("l" => 27.4, "h" => 32.2),
16 array("l" => 32.3, "h" => 44.8),
17 array("l" => 44.8, "h" => -1),
18 );
19 $poruke = array(
20 array("s" => "BMI prenizak", "l" => "Trebali biste poveæati tjelesnu te¾inu."),
21 array("s" => "BMI idealan", "l" => "Poku¹ajte zadr¾ati Va¹u te¾inu."),
22 array("s" => "BMI malo iznad normale", "l" => "Za sada Va¹e stanje jo¹ nije zabrinjavajuæe, no ipak poku¹ajte kontrolirati Va¹u te¾inu."),
23 array("s" => "BMI visok", "l" => "Po¾eljno je smanjiti tjelesnu te¾inu."),
24 array("s" => "BMI previsok", "l" => "Razmislite o tome kako da smanjite te¾inu. U suprotnom biste mogli imati ozbiljnih zdravstvenih problema."),
25 array("s" => "BMI izrazito visok", "l" => "Obratite se svome lijeèniku. Ukoliko ne smanjite tjelesnu te¾inu, mogli biste imati ozbiljnih zdravstvenih problema.")
26 );
27 function Zaokruzi($val, $n = 1) {
28 $mul = 1;
29 for ($i = 0; $i < $n; $i++) $mul *= 10;
30 return ceil($val * $mul) / $mul;
31 }
32 if (($izracunaj_x || $izracunaj_y) && $visina && $tezina && $spol) {
33 $vis = $visina / 100;
34 $bmi = Zaokruzi($tezina / ($vis * $vis));
35 $tpl->assign("bmi", $bmi);
36 $poruka = "";
37 $result = array();
38 if ($spol == "M") $result = $result_m;
39 if ($spol == "Z") $result = $result_z;
40 for ($i = 0; $i < count($result); $i++) {
41 list($l, $h) = array($result[$i]["l"], $result[$i]["h"]);
42 $this_msg = false;
43 if (!$this_msg && ($l < 0) && ($bmi < $h)) $this_msg = true;
44 if (!$this_msg && ($h < 0) && ($bmi > $l)) $this_msg = true;
45 if (!$this_msg && ($bmi >= $l && $bmi <= $h)) $this_msg = true;
46 if ($this_msg) $poruka = $poruke[$i]["s"].". ".$poruke[$i]["l"];
47 }
48 $tpl->assign("poruka", $poruka);
49 }
50 $tpl->assign("result_m", $result_m);
51 $tpl->assign("result_z", $result_z);
52 $tpl->assign("poruke", $poruke);
53 $tpl->assign("visina", $visina);
54 $tpl->assign("tezina", $tezina);
55 $tpl->assign("spol", $spol ? $spol : "M");
56 $tpl->assign("m_1", "BMI prenizak. Trebali biste poveæati tjelesnu te¾inu.");
57 $tpl->assign("m_2", "BMI idealan. Poku¹ajte zadr¾ati Va¹u te¾inu.");
58 $tpl->assign("m_3", "BMI malo iznad normale. Za sada Va¹e stanje jo¹ nije zabrinjavajuæe, no ipak poku¹ajte kontrolirati Va¹u te¾inu.");
59 $tpl->assign("m_4", "BMI visok. Po¾eljno je smanjiti tjelesnu te¾inu.");
60 $tpl->assign("m_5", "BMI previsok. Razmislite o tome kako da smanjite te¾inu. U suprotnom biste mogli imati ozbiljnih zdravstvenih problema.");
61 $tpl->assign("m_6", "BMI izrazito visok. Obratite se svome lijeèniku. Ukoliko ne smanjite tjelesnu te¾inu, mogli biste imati ozbiljnih zdravstvenih problema.");
62 ?>

  ViewVC Help
Powered by ViewVC 1.1.26