PHP表有两列

PHP表有两列,php,html-table,Php,Html Table,例如,我如何在PHP中创建包含两列和10个变量的表(没有循环) 例如: $var1= $row['name']; $var2= $row['age']; 我想在表格中显示的方式: ______________________ | Customer Name | $var1| | Customer Age | $var2| 无回路: echo ' <table> <tr> <td>Customer Name</td&g

例如,我如何在PHP中创建包含两列和10个变量的表(没有循环)

例如:

$var1= $row['name'];
$var2= $row['age'];
我想在表格中显示的方式:

    ______________________
   | Customer Name | $var1|
   | Customer Age  | $var2|
无回路:

echo '
<table>
  <tr>
    <td>Customer Name</td>
    <td>', $var1, '</td>
  </tr>
  <tr>
    <td>Customer Age</td>
    <td>', $var2, '</td>
  </tr>
  <tr>
    <td>Customer ...</td>
    <td>', $var3, '</td>
  </tr>
</table>';
echo'
客户名称
“,$var1,”
客户年龄
“,$var2,”
顾客
“,$var3,”
';
带foreach循环

$myFields = array("Customer Name" => $row['Name'], 
                  "Customer Age"  => $row['Age']);

echo '<table><tr>';

foreach($myFields as $field_title => $field_value)
   echo '<td>', $field_title, '</td>
         <td>', $field_value, '</td>';

echo '</tr></table>';
$myFields=array(“客户名称”=>$row['Name'],
“客户年龄”=>$row['Age']);
回声';
foreach($myFields作为$field\u title=>$field\u值)
回显“”,$field\u title,'
“,$field_值,”;
回声';
无循环:

echo '
<table>
  <tr>
    <td>Customer Name</td>
    <td>', $var1, '</td>
  </tr>
  <tr>
    <td>Customer Age</td>
    <td>', $var2, '</td>
  </tr>
  <tr>
    <td>Customer ...</td>
    <td>', $var3, '</td>
  </tr>
</table>';
echo'
客户名称
“,$var1,”
客户年龄
“,$var2,”
顾客
“,$var3,”
';
带foreach循环

$myFields = array("Customer Name" => $row['Name'], 
                  "Customer Age"  => $row['Age']);

echo '<table><tr>';

foreach($myFields as $field_title => $field_value)
   echo '<td>', $field_title, '</td>
         <td>', $field_value, '</td>';

echo '</tr></table>';
$myFields=array(“客户名称”=>$row['Name'],
“客户年龄”=>$row['Age']);
回声';
foreach($myFields作为$field\u title=>$field\u值)
回显“”,$field\u title,'
“,$field_值,”;
回声';

简单。使用以下语法:

<table >
    <tr>
        <th>Customer Name</th>
        <td><?php echo $var1; ?></td>
    </tr>
    <tr>
        <th>Customer Age</th>
        <td><?php echo $var2; ?></td>
    </tr>
    <tr>
        <th>Customer Name</th>
        <td><?php echo $var3; ?></td>
    </tr>
    <tr>
        <th>Customer Age</th>
        <td><?php echo $var4; ?></td>
    </tr>
    <tr>
        <th>Customer Name</th>
        <td><?php echo $var5; ?></td>
    </tr>
    <tr>
        <th>Customer Age</th>
        <td><?php echo $var6; ?></td>
    </tr>
    <tr>
        <th>Customer Name</th>
        <td><?php echo $var7; ?></td>
    </tr>
    <tr>
        <th>Customer Age</th>
        <td><?php echo $var8; ?></td>
    </tr>
    <tr>
        <th>Customer Name</th>
        <td><?php echo $var9; ?></td>
    </tr>
    <tr>
        <th>Customer Age</th>
        <td><?php echo $var10; ?></td>
    </tr>
</table>

客户名称
客户年龄
客户名称
客户年龄
客户名称
客户年龄
客户名称
客户年龄
客户名称
客户年龄

简单。使用以下语法:

<table >
    <tr>
        <th>Customer Name</th>
        <td><?php echo $var1; ?></td>
    </tr>
    <tr>
        <th>Customer Age</th>
        <td><?php echo $var2; ?></td>
    </tr>
    <tr>
        <th>Customer Name</th>
        <td><?php echo $var3; ?></td>
    </tr>
    <tr>
        <th>Customer Age</th>
        <td><?php echo $var4; ?></td>
    </tr>
    <tr>
        <th>Customer Name</th>
        <td><?php echo $var5; ?></td>
    </tr>
    <tr>
        <th>Customer Age</th>
        <td><?php echo $var6; ?></td>
    </tr>
    <tr>
        <th>Customer Name</th>
        <td><?php echo $var7; ?></td>
    </tr>
    <tr>
        <th>Customer Age</th>
        <td><?php echo $var8; ?></td>
    </tr>
    <tr>
        <th>Customer Name</th>
        <td><?php echo $var9; ?></td>
    </tr>
    <tr>
        <th>Customer Age</th>
        <td><?php echo $var10; ?></td>
    </tr>
</table>

客户名称
客户年龄
客户名称
客户年龄
客户名称
客户年龄
客户名称
客户年龄
客户名称
客户年龄

您可以使用以下内容:

$array = array();
$array[0]["name"];
$array[0]["age"];
或者,您可以使用一个循环:

$i=0;
while($i<10){
$array[$i]["name"]=...;
$i++;
}

print_r($array);
$i=0;

而($i您可以使用以下内容:

$array = array();
$array[0]["name"];
$array[0]["age"];
或者,您可以使用一个循环:

$i=0;
while($i<10){
$array[$i]["name"]=...;
$i++;
}

print_r($array);
$i=0;

whith out LOOP…..为什么你想这么做!whith out LOOP…..为什么你想这么做!