创建一个将高度乘以权重的表

  • 本文关键字:权重 高度 一个 创建 php
  • 更新时间 :
  • 英文 :


如何创建一个高度乘以权重的表?

我不知道怎么算出来!

我正在尝试创建一个BMI计算器。

// collect values from a form sent with method=get
$min_weight = mysql_real_escape_string($_GET["min_weight"]);
$max_weight = mysql_real_escape_string($_GET["max_weight"]);
$min_height = mysql_real_escape_string($_GET["min_height"]);
$max_height = mysql_real_escape_string($_GET["max_height"]);
?>
<table>
    <tr>
      <td>Key:</td>
      <td class="good show">Healthy (20-25)</td>
      <td cla ss="warning show">Overweight (25-30)</td>
      <td class="bad show">Unhealthy ( -20 or 30+)</td>
    </tr>
  </table>
<table border="1">
<?php 
echo "<tr><td>Height &rarr;<br>Weight &darr;</td>";
for ( $i = $min_height; $i <= $max_height; $i+=5 ) 
{
    echo "<td>{$i}</td>";
}
echo "</tr>";
for ( $j = $min_weight; $j <= $max_weight; $j+=5 ) 
{
    echo "<tr>";
    echo "<td>{$j}</td>";
    echo "</tr>";
}

这应该可以完成工作,我还放了一些isset():

<?php
// collect values from a form sent with method=get
$min_weight = isset($_GET["min_weight"]) ? mysql_real_escape_string($_GET["min_weight"]):0;
$max_weight = isset($_GET["max_weight"]) ? mysql_real_escape_string($_GET["max_weight"]):0;
$min_height = isset($_GET["min_height"]) ? mysql_real_escape_string($_GET["min_height"]):0;
$max_height = isset($_GET["max_height"]) ? mysql_real_escape_string($_GET["max_height"]):0;
?>
<table>
    <tr>
      <td>Key:</td>
      <td class="good show">Healthy (20-25)</td>
      <td class="warning show">Overweight (25-30)</td>
      <td class="bad show">Unhealthy ( -20 or 30+)</td>
    </tr>
  </table>
<?php
$table = '<table border="1">';
$table .= '<tr><td>Height &rarr;<br>Weight &darr;</td>';
for ($i = $min_height;$i <= $max_height;$i += 5){
    $table .= "<td>$i</td>";
}
$table .= "</tr>";
for($j = $min_weight; $j <= $max_weight;$j += 5){
    $table .= "<tr><td>$j</td>";
    for ($i = $min_height;$i <= $max_height;$i += 5){
        $table .= '<td>'. $i * $j .'</td>';
    }
    $table .= '</tr>';
}
$table .= '</table>';
echo $table;
?>

即使这工作是错误的有表边界外的php标签?

<table>
    <tr>
      <td>Key:</td>
      <td class="good show">Healthy (20-25)</td>
      <td class="warning show">Overweight (25-30)</td>
      <td class="bad show">Unhealthy ( -20 or 30+)</td>
    </tr>
  </table>
<table border="1">
<?php 
echo "<tr><td>Height &rarr;<br>Weight &darr;</td>";
for ( $j = $min_height; $j <= $max_height; $j+=5 ) 
{
echo "<td>{$j}</td>";
}
for ( $i = $min_weight; $i <= $max_weight; $i+=5 ) 
{
echo "<tr><td>{$i}</td>";
for ( $j = $min_height; $j <= $max_height; $j+=5 ) 
{
$var = number_format(($i)/(($j/100)*($j/100)),'2','.','');
{
echo "<td class='warning'>";
}
echo $var;
echo "</td>";
}
echo "</tr>";
}
?>
</table>

最新更新