0

How to put there size, I want to display edge image in 400X400 format:

  • height = 400
  • width = 400

Please give the code size in 400X400, thanks.

Here is the code:

<?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>";
    }
?>

3 Answers 3

4

I don't know if I understood correctly:

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

that's all you need if you want to set the dimensions

Sign up to request clarification or add additional context in comments.

2 Comments

height=\"400\" width=\"400\" /> Seriously? How do we know if it is in pixels? shouldn't you include px
Height and width attributes DON'T expect px on the end. They never have. They expect an integer which means pixels, or a percentage. However they are depreciated. Height and width CSS properties do expect px or %.
1

You just need to add a style attribute style="width:400px; height:400px;"

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

Comments

1

Please check my code

list($width, $height, $type, $attr) = getimagesize("PATH_OF_THE_IMAGE/".$row['filename']);

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.