Jump to content

echo syntax


pj_canada

Recommended Posts

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.