OriginalSunny Posted March 8, 2006 Share Posted March 8, 2006 Hi,i am trying to change the size of the pictures i want to display in php. The problem is that when i try and do it the picture simply dissapears. In html i used width=100 and height =100 as shown below and it worked:[i] <a href="simfreeMot.php"> <img src="Motorolla Logo.bmp" width=100 height=100></a>[/i]I am using the code below to show the pic in php:[i]echo "<img src='{$products[$i]['phonepic']}'>";[/i]This works however when i try and change the size using:[i]echo "<img src='{$products[$i]['phonepic']} width=100 height=100'>";[/i]It comes up with no picture(as if there is a broken link to the picture. There is a blank page produced when i try:[i]echo "<img src='{$products[$i]['phonepic'] width=100 height=100}'>";[/i]If you know how to do this properly please let me know.Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/4432-pictures-in-php/ Share on other sites More sharing options...
kenrbnsn Posted March 8, 2006 Share Posted March 8, 2006 You almost had it with this code[code]<?php echo "<img src='{$products[$i]['phonepic']} width=100 height=100'>"; ?>[/code]Try this (you had the terminating single quote in the wrong place)[code]<?php echo "<img src='{$products[$i]['phonepic']}' width=100 height=100>"; ?>[/code]or[code]<?php echo '<img src="' . $products[$i]['phonepic'] . '" width=100 height=100>'; ?>[/code]In the above snippet, I interchanged the single and double quotes and using the string concatenation operator to form the final string.Ken Quote Link to comment https://forums.phpfreaks.com/topic/4432-pictures-in-php/#findComment-15399 Share on other sites More sharing options...
ToonMariner Posted March 8, 2006 Share Posted March 8, 2006 Bear in mind altering the height and width values of an image will simply distort them and in teh vast majority of cases this makes them look very poor - unprofessional even!You can grab the size of the image on upload, or better still resample and create an image of the correct dimensions....check out the gdlibrary for such magical trickery Quote Link to comment https://forums.phpfreaks.com/topic/4432-pictures-in-php/#findComment-15409 Share on other sites More sharing options...
obsidian Posted March 8, 2006 Share Posted March 8, 2006 [!--quoteo(post=352858:date=Mar 8 2006, 09:26 AM:name=kenrbnsn)--][div class=\'quotetop\']QUOTE(kenrbnsn @ Mar 8 2006, 09:26 AM) [snapback]352858[/snapback][/div][div class=\'quotemain\'][!--quotec--]You almost had it with this code[code]<?php echo "<img src='{$products[$i]['phonepic']} width=100 height=100'>"; ?>[/code]Try this (you had the terminating single quote in the wrong place)[code]<?php echo "<img src='{$products[$i]['phonepic']}' width=100 height=100>"; ?>[/code][/quote]also, keep in mind that if you're going for validation, ALL your attribute values need to have quotes around them. so, putting quotes around the height and width as well is best practice:[code]<?phpecho "<img src='{$products[$i][phonepic]}' width='100' height='100'>";?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/4432-pictures-in-php/#findComment-15417 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.