创建将循环并列出项目的表

时间:2013-12-05 23:47:04

标签: php html

我想将我的div变换成一个表格,以便用信息看到这些项目。

<div class="text">List Of Product </div>
    <div class="view1"><?php
           include('config.php');

$result2 = mysql_query("SELECT * FROM category");

while($row2 = mysql_fetch_array($result2)) {
    $ble=$row2['id'];
    $result3 = mysql_query("SELECT * FROM athan_products where product_id='$ble'");

    $row3 = mysql_fetch_array($result3);

    echo '<div class="templatemo_pizza_box"> <a rel="facebox" href=portal.php?id=' . $row3["product_id"] . '><img alt="Motor" src="images/motor/'.$row3['product_photo'].'" width="65px" height="65px" /></a>';
    echo '<div class="textbox"> '.$row3['partsname'].' </div>';

    echo '</div>';

}

?></div>

1 个答案:

答案 0 :(得分:0)

试试这个:

<div class="text">List Of Product </div>
<table class="view1">
    <?php
        include('config.php');
        $result2 = mysql_query("SELECT * FROM category");
        while ($row2 = mysql_fetch_array($result2)) {
            $ble = $row2['id'];
            $result3 = mysql_query("SELECT * FROM athan_products where product_id='$ble'");
            echo "<tr>";
            while ($row3 = mysql_fetch_array($result2)) {
                echo '<td class="templatemo_pizza_box"><a rel="facebox" href=portal.php?id=' . $row3["product_id"] . '><img alt="Motor" src="images/motor/' . $row3['product_photo'] . '" width="65px" height="65px" /></a></td>';
                echo '<td class="textbox"> ' . $row3['partsname'] . '</td>';
            }
            echo '</tr>';
        }
    ?>
</table>
相关问题