У меня есть HTML-страница с переключателями, которые вы можете выбрать. Один — это возрастной диапазон, а другой — диапазон зарплат. Они обрабатываются php-файлом, и я хочу напечатать
Заявление о том, как пользователь сравнивает медиану для своего возраста
Пока я печатаю только возрастной диапазон пользователя и диапазон зарплаты. Я не могу понять, как распечатать другие.
<table>
<tr>
<td>
Age Range</td>
<td colspan="2">
Salary Range</td>
</tr>
<tr>
<td>
<input id="Radio1" checked="checked" name="R1" type="radio" value="V1" />15 to
24 Years</td>
<td>
<input id="Radio7" checked="checked" name="R7" type="radio" value="V1" />$15,000
to $24,999</td>
<td>
<input id="Radio13" name="R7" type="radio" value="V1" />$75,000
to $84,999</td>
</tr>
<tr>
<td>
<input id="Radio2" name="R1" type="radio" value="V1" />25 to
34 Years</td>
<td>
<input id="Radio8" name="R7" type="radio" value="V1" />$25,000
to $34,999</td>
<td>
<input id="Radio14" name="R7" type="radio" value="V1" />$85,000
to $94,999</td>
</tr>
<tr>
<td>
<input id="Radio3" name="R1" type="radio" value="V1" />35 to
44 Years</td>
<td>
<input id="Radio9" name="R7" type="radio" value="V1" />$35,000
to $44,999</td>
<td>
<input id="Radio15" name="R7" type="radio" value="V1" />$95,000
to $104,999</td>
</tr>
<tr>
<td>
<input id="Radio4" name="R1" type="radio" value="V1" />45 to
54 Years</td>
<td>
<input id="Radio10" name="R7" type="radio" value="V1" />$45,000
to $54,999</td>
<td>
<input id="Radio16" name="R7" type="radio" value="V1" />$105,000
to $114,999</td>
</tr>
<tr>
<td>
<input id="Radio5" name="R1" type="radio" value="V1" />55 to
64 Years</td>
<td>
<input id="Radio11" name="R7" type="radio" value="V1" />$55,000
to $64,999</td>
<td>
<input id="Radio17" name="R7" type="radio" value="V1" />$115,000
to $124,999</td>
</tr>
<tr>
<td>
<input id="Radio6" name="R1" type="radio" value="V1" />65
Years and Older</td>
<td>
<input id="Radio12" name="R7" type="radio" value="V1" />$65,000
to $74,999</td>
<td>
<input id="Radio18" name="R7" type="radio" value="V1" />$125,000
and up</td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
</tr>
</table>
<input type="submit" name="submit" value="See Where You Stand">
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>Income</title>
<style>
body { font-family: Helvetica, Arial, sans-serif; }
body { font-size: 85%; }</style></head>
<body style="background-color:lightgray; ">
<form action="AgeGroupSalaryRange.php" method="post" name="agegroup">
<h1>Income</h1>
<table>
<tr>
<td>
Age Range</td>
<td colspan="2">
Salary Range</td>
</tr>
<tr>
<td>
<input id="Radio1" checked="checked" name="R1" type="radio" value="V1" />15 to
24 Years</td>
<td>
<input id="Radio7" checked="checked" name="R7" type="radio" value="V1" />$15,000
to $24,999</td>
<td>
<input id="Radio13" name="R7" type="radio" value="V1" />$75,000
to $84,999</td>
</tr>
<tr>
<td>
<input id="Radio2" name="R1" type="radio" value="V1" />25 to
34 Years</td>
<td>
<input id="Radio8" name="R7" type="radio" value="V1" />$25,000
to $34,999</td>
<td>
<input id="Radio14" name="R7" type="radio" value="V1" />$85,000
to $94,999</td>
</tr>
<tr>
<td>
<input id="Radio3" name="R1" type="radio" value="V1" />35 to
44 Years</td>
<td>
<input id="Radio9" name="R7" type="radio" value="V1" />$35,000
to $44,999</td>
<td>
<input id="Radio15" name="R7" type="radio" value="V1" />$95,000
to $104,999</td>
</tr>
<tr>
<td>
<input id="Radio4" name="R1" type="radio" value="V1" />45 to
54 Years</td>
<td>
<input id="Radio10" name="R7" type="radio" value="V1" />$45,000
to $54,999</td>
<td>
<input id="Radio16" name="R7" type="radio" value="V1" />$105,000
to $114,999</td>
</tr>
<tr>
<td>
<input id="Radio5" name="R1" type="radio" value="V1" />55 to
64 Years</td>
<td>
<input id="Radio11" name="R7" type="radio" value="V1" />$55,000
to $64,999</td>
<td>
<input id="Radio17" name="R7" type="radio" value="V1" />$115,000
to $124,999</td>
</tr>
<tr>
<td>
<input id="Radio6" name="R1" type="radio" value="V1" />65
Years and Older</td>
<td>
<input id="Radio12" name="R7" type="radio" value="V1" />$65,000
to $74,999</td>
<td>
<input id="Radio18" name="R7" type="radio" value="V1" />$125,000
and up</td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
</tr>
</table>
<input type="submit" name="submit" value="See Where You Stand">
</form>
</body>
</html>
Эта функция вернет медиану массива значений.
<?php
function getMedian($arr) {
sort($arr);
$count = count($arr);
$middleval = floor(($count-1)/2);
if ($count % 2) {
$median = $arr[$middleval];
} else {
$low = $arr[$middleval];
$high = $arr[$middleval+1];
$median = (($low+$high)/2);
}
return $median;
}
Я изо всех сил пытаюсь понять вашу форму / код и посмотреть, каким может быть этот массив, но, надеюсь, это поможет.
Других решений пока нет …