Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/279.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在PHP中创建产品的网格视图_Php_Html_Mysql_Css - Fatal编程技术网

在PHP中创建产品的网格视图

在PHP中创建产品的网格视图,php,html,mysql,css,Php,Html,Mysql,Css,非常新的PHP,请容忍 正如您从我的代码片段中所看到的,我只是将产品信息显示在一行下,然后使用while重复循环。然后很明显,我的相关数据只显示在一列中,一列在另一列下 while ($row = mysqli_fetch_row($result)){ echo "<img src=\"images/album1.jpg\"/><br>"; //this will eventually show the product image echo "<a

非常新的PHP,请容忍

正如您从我的代码片段中所看到的,我只是将产品信息显示在一行下,然后使用while重复循环。然后很明显,我的相关数据只显示在一列中,一列在另一列下

while ($row = mysqli_fetch_row($result)){

    echo "<img src=\"images/album1.jpg\"/><br>"; //this will eventually show the product image
    echo "<a href=\"product.php?id=$row[0]\">$row[1] </a><br>"; //this shows the product name
    echo "<strong>&pound$row[2]</strong><br>"; //this shows the product price

            }
while($row=mysqli\u fetch\u row($result)){
echo“
”;//这将最终显示产品图像 echo“
”;//显示产品名称 echo“£$行[2]
”;//这显示了产品价格 }
如何创建网格视图,例如使用列显示数据?我想这将是一种需要添加的循环,可能使用表来显示我的数据


非常感谢您的帮助。

您可以通过创建div来点此,并将该div向左浮动,这将创建网格视图

while ($row = mysqli_fetch_row($result)){
    echo "<div class='container'>";
    echo "<img src=\"images/album1.jpg\"/><br>"; //this will eventually show the product image
    echo "<a href=\"product.php?id=$row[0]\">$row[1] </a><br>"; //this shows the product name
    echo "<strong>&pound$row[2]</strong><br>"; //this shows the product price
    echo "</div>";
    }
你可以
还可以设置div的最大高度和宽度。谢谢你,我的朋友。
.container{
  float:left;
}