0

如何显示水平网格。我有垂直显示的代码。但我需要它水平显示。

<?php

$connect=mysql_connect("localhost","root","user");
mysql_selectdb("form");
$result=mysql_query("SELECT * FROM cath");
//echo "The details are....";

$dyn_table = '<table border="2" cellpadding="10">';

while($cath=mysql_fetch_array($result))
{

    $ID=$cath["ID"];
    $name=$cath["name"];
    $email=$cath["email"];
    $number=$cath["number"];
    $org=$cath["org"];
    $message=$cath["message"];

        if ($cath==$cath) 
        { 
        $dyn_table .= '<tr><td>' . $name . '</td>';
        $dyn_table .= '<tr><td>' . $email . '</td>';
        $dyn_table .= '<tr><td>' . $number . '</td>';
        $dyn_table .= '<tr><td>' . $org . '</td>';
        $dyn_table .= '<tr><td>' . $message . '</td>';
        } 

}   

$dyn_table .= '</tr></table>';
?>

<html>
<body>
<h3>PHP GRID LAYOUT</h3>
<?php 
echo $dyn_table;
?>
</body>
</html>

你能帮我解决这个问题吗?等待最佳解决方案。

谢谢

卡西

4

1 回答 1

0

您可以将表行创建移动到 if 语句的顶部和底部吗?

while($cath=mysql_fetch_array($result))
{
    $ID=$cath["ID"];
    $name=$cath["name"];
    $email=$cath["email"];
    $number=$cath["number"];
    $org=$cath["org"];
    $message=$cath["message"];

    if ($cath==$cath) 
    {
        $dyn_table .= '<tr>'; 
        $dyn_table .= '<td>' . $name . '</td>';
        $dyn_table .= '<td>' . $email . '</td>';
        $dyn_table .= '<td>' . $number . '</td>';
        $dyn_table .= '<td>' . $org . '</td>';
        $dyn_table .= '<td>' . $message . '</td>';
        $dyn_table .= '</tr>'; 
    }
}

$dyn_table .= '</table>';   
于 2013-04-30T07:46:50.560 回答