如何放置尺寸,我想以400X400格式显示边缘图像:
请在400X400中给出代码大小,谢谢。
以下是代码:
<?php
// Grab the data from our people table
$sql = "select * from njerz";
$result = mysql_query($sql) or die ("Could not access DB: " . mysql_error());
while ($row = mysql_fetch_assoc($result)) {
echo "<div class=\"picture\">";
echo "<p>";
// Note that we are building our src string using the filename from the database
echo $row['fname'] . " " . $row['lname'] . "<br />";
echo "<img src=\"images/" . $row['filename'] . "\" alt=\"\" /><br ;
echo "</p>";
echo "</div>";
}
?>
答案 0 :(得分:3)
我不知道我是否理解正确:
echo "<img src=\"images/" . $row['filename'] . "\" alt=\"\" height=\"400\" width=\"400\" /><br />";
如果你想设置尺寸
,那就是你所需要的答案 1 :(得分:1)
您只需添加一个样式属性style="width:400px; height:400px;"
echo '<img src="images/'. $row['filename'] .'" style="width:400px; height:400px;" alt="" /><br />';
答案 2 :(得分:1)
请检查我的代码
list($width, $height, $type, $attr) = getimagesize("PATH_OF_THE_IMAGE/".$row['filename']);
echo "<img src=\"images/" . $row['filename'] . "\" alt=\"\" height=\"".$height."\" width=\"".$width."\" /><br />";