pj_canada Posted June 24, 2008 Share Posted June 24, 2008 I've been at this for hours!!! with no luck so wonder if anyone can help... I'm using a common image resize function below to constrain the image proportions for a dynamic image. <?php //declare your variables function imageResize($width, $height, $target) { //takes the larger size of the width and height and applies the formula. if ($width > $height) { @$percentage = ($target / $width); } else { @$percentage = ($target / $height); } //gets the new value and applies the percentage, then rounds the value $width = round($width * $percentage); $height = round($height * $percentage); //returns the new sizes in html image tag format... return "width=\"$width\" height=\"$height\""; } ?> I can get it to work fine by using the following code: <img src="<?php echo $row_Recordset101['pImage']; ?>" <?php echo imageResize($mypicture[0], $mypicture[1], $target); ?>> However, I want to use the echo comand inside an IF.. ELSE statement and for the life of me just can't seem to get the syntax correct (after 3 hours I'm reduced to random attaempts at anything :-\ ) There have been many attempts such as: echo '<a href=' .$statname. '.php' . '><img src="'.$image.'" 'imageResize($mypicture[0], $mypicture[1], $target);' />'.'</a>' ; If anyone can shed some light on how this is achieved and any good sources of info about the RULES of this kind of syntax I would be grateful. Paul Link to comment https://forums.phpfreaks.com/topic/111604-echo-syntax/ Share on other sites More sharing options...
webent Posted June 24, 2008 Share Posted June 24, 2008 Try this... echo '<a href="'.$statname.'"><img src="'.$image.'"'.imageResize($mypicture[0], $mypicture[1], $target);.'" /></a>'; I'm just not real clear on having that imageResize inside of it... if it works great... Link to comment https://forums.phpfreaks.com/topic/111604-echo-syntax/#findComment-572864 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.