0

如何放置尺寸,我想以 400X400 格式显示边缘图像:

  • 高度 = 400
  • 宽度 = 400

请给出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>";
    }
?>
4

3 回答 3

4

我不知道我是否理解正确:

echo "<img src=\"images/" . $row['filename'] . "\" alt=\"\" height=\"400\" width=\"400\" /><br />";

如果你想设置尺寸,这就是你所需要的

于 2012-12-23T22:34:45.963 回答
1

你只需要添加一个样式属性style="width:400px; height:400px;"

echo '<img src="images/'. $row['filename'] .'" style="width:400px; height:400px;" alt="" /><br />';
于 2012-12-23T23:22:01.947 回答
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 />";
于 2014-05-24T10:02:53.527 回答