我想用PHP创建一个html表

我想用PHP创建一个html表,php,Php,嗨,这是我尝试的代码,第一个while语句适用于rowsworks的weights0,但我无法让它与columnsheights一起工作。如果最小高度输入值为20,最大高度输入值为50,则列将如下所示20 25 30 35 40 45 50。我的代码目前适用于行,但不适用于列,有人能帮忙吗 <?php $rowiStep = 5; $coliStep = 5; // Get these $iweightMin = $_GET["min_weight"]; $iweightMax = $_G

嗨,这是我尝试的代码,第一个while语句适用于rowsworks的weights0,但我无法让它与columnsheights一起工作。如果最小高度输入值为20,最大高度输入值为50,则列将如下所示20 25 30 35 40 45 50。我的代码目前适用于行,但不适用于列,有人能帮忙吗

<?php
$rowiStep = 5;
$coliStep = 5;
// Get these
$iweightMin = $_GET["min_weight"];
$iweightMax = $_GET["max_weight"];
$iheightMin = $_GET["max_height"];
$iheightmax = $_GET["min_height"];

$iCur = $iweightMin;
$iCol = $iheightMin;
print('<table class="table">');
print('<tr ><td>Height/</br>Weight</td>');
while ($iCur <= $iweightMax) {
    printf('<tr><td>%d</td></tr>', $iCur);
    $iCur += $rowiStep;
}

$rowiCol = $iheightMin;

while ($iCol <= $iheightmax) {
   printf('<tr><td></td>', $iCol);
   $iCol += $rowiCol;
}

print ('</tr>');
print('</table>');  

?>

如果您希望打印身高/体重矩阵;试试这个:

$rowiStep = 5;
$coliStep = 5;
$output = array(
    '<table>'
);

for( $row_val = $_GET['min_weight'], $row_max <= $_GET['max_weight'];
     $row_val < $row_max;
     $row_val += $rowistep )
{
    $output[] = '<tr><td>' . $row_val . '</td>';
    for( $col_val = $_GET['min_height'], $col_val <= $_GET['max_height'];
         $col_val < $col_max;
         $col_val += $colistep )
    {
        $output[] = '<td>' . $col_val . '</td>';
    }
    $output[] = '</tr>';
}
$output[] = '</table>';
echo implode( "\n", $output );

您在寻找什么输出?

如果您是说您没有获得列集的输出,则列的printf中缺少了%d。HTML表格是逐行而不是逐列形成的,因此您的方法没有意义。您能提供一个示例,说明您想要的输出,以及用于获取输出的输入吗?查看当前代码,我看到很多不平衡的标签。许多打开的tr未关闭。如果你发布你的实现的目的是什么,也许会有帮助。我基本上是想用列而不是行来做以下事情。你介意编辑你的原始问题,包括你想要的输出和示例吗?
|min_weight            |min_height|min_height+colIStep|min_height+2colIstep|...|
|min_weight + rowIstep |min_height|min_height+colIStep|min_height+2colIstep|...|
|min_weight + 2rowIstep|min_height|min_height+colIStep|min_height+2colIstep|...|
|...|