这是我正在制作的网站上的画廊代码
<h3>Gallery</h3>
<?php
include"includes/connection.php";
$sql = "select * from kategorije";
$res = mysqli_query($con, $sql);
while($row = mysqli_fetch_assoc($res))
{
?>
<h4 class="text-center"><?php echo ucwords($row['naziv']); ?></h4>
<?php
$id = $row['sifra'];
$sql1 = "select * from rad where kategorija = $id";
$res1 = mysqli_query($con, $sql1);
$n = mysqli_num_rows($res1);
if($n>0)
{
while($row1 = mysqli_fetch_assoc($res1))
{
$pid = $row1['sifra'];
?>
<div class="col-md-2 col_1">
<a href="single.php?id=<?php echo $pid ?>"><img src="uploads/<?php echo $row1['datoteka']; ?>" class="img-responsive" alt=""/></a>
</div>
<?php
}
}else{
?>
<div class="col-md-2 col_1">
<h6>No Images</h6>
</div>
<?php
}
?>
<div class="clearfix"></div>
<?php
}
?>
我需要让图库中的所有照片在上传时具有相同的高度和宽度,但我不知道如何做。我试图插入这段代码,但它不起作用:
echo"<img src='$dir_path$files[$i]'style='width:150px;height:200px;'>
我也在 CSS 中尝试过,但它也不起作用。
最佳答案
由于您只想以另一种尺寸显示它们,您可以通过您尝试过的方式实现这一点,但要使用正确的语法。我希望它是您想要调整大小的图像的这行代码:
<a href="single.php?id=<?php echo $pid ?>"><img src="uploads/<?php echo `$row1['datoteka']; ?>" class="img-responsive" height="200" width="150" alt=""/></a>`
让我知道它对您有用。如果这不是您想执行的行,请记住您只需遵循以下语法:
<img src="http://url.com/pic.png" width="150" height="200">
就是这样。 :)
关于php - 如何在 PHP 中制作图库照片,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41741999/