Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/74.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_Gallery - Fatal编程技术网

Php图库表

Php图库表,php,html,gallery,Php,Html,Gallery,我需要做一个表,最好每行4-5张图片,但它会继续在我的页面上。任何帮助都将不胜感激 <?php $host = "localhost"; $user = "root"; $password = ""; $database = "imageupload"; $query = "SELECT id, url, name from images "; $connect = mysqli_connect($host,$user,$password,$database) or die("Pro

我需要做一个表,最好每行4-5张图片,但它会继续在我的页面上。任何帮助都将不胜感激

<?php
$host = "localhost";

$user = "root";
$password = "";
$database = "imageupload";

$query = "SELECT id, url, name from images ";

$connect = mysqli_connect($host,$user,$password,$database) or die("Problem connecting.");
$result = mysqli_query($connect,$query) or die("Bad Query.");

mysqli_close($connect);

while($row = $result->fetch_array())
{

    echo "<td>";

    echo "<td><h2><img src=" . $row['url'] . " width=150 height=150/></h2></td>";


    echo "<td><h2>" .$row['name'] . "</h2></td>";


    echo "</td>";
}
?>

<table>

您可以尝试以下方法:

echo "<table><tr>";
foreach($row = $result->fetch_array()) {
    if($row['id'] % 4 == 0) { //Change it to 5 if you want 5 images per row
        echo "</tr><tr>";
    }
    echo "<td><img src='" . $row['url'] . "' /></td>";
}
echo "</tr></table>";
echo”“;
foreach($row=$result->fetch\u array()){
如果($row['id']%4==0){//如果希望每行有5个图像,请将其更改为5
回声“;
}
回声“;
}
回声“;

您包含了一些代码,这些代码看起来好像是在尝试执行您需要执行的操作。它有什么作用?您过早地关闭了连接,并且您的
标签不正确。语法:
..
是你的代码。而且,我实际上没有看到任何
s。@don't也这样;语法错误层出不穷,大多数是HTML,其中一个是mysql。