Jump to content

[SOLVED] creating functions...


jesushax

Recommended Posts

Hi i have this below code that i just created

 

im wondering how i can put this code into a function so i just define where the image comes from then echo the widths and heights into that url + 10

 

thanks

 

<?php 
$Imagesize = getimagesize($_SERVER['DOCUMENT_ROOT']."/portfolio/images/".$rsEdit["ClientLogo"]."");
$width = $Imagesize[0] + 40; 
$height = $Imagesize[1] + 40; 
?>
  <td><a href="/portfolio/images/<?php echo $rsEdit["ClientLogo"]; ?>" onclick="NewWindow(this.href,'name','<?php echo $width;?>','<?php echo $height;?>','yes');return false"><?php echo $rsEdit["ClientLogo"]?></a> </td>

 

 

Link to comment
https://forums.phpfreaks.com/topic/109367-solved-creating-functions/
Share on other sites

Guest Xanza

Your question was fairly vague, and I dident know what you were really going for... So I did my best:

 

<?php

function myImage(){
  echo '<a href={$path}{$rsEdit["ClientLogo"]} onclick=NewWindow(this.href,"name","{$width}","{$height}","yes"); return false>{$rsEdit["CientLogo"]}</a>';
}

?>

Well, from your original post i was going to suggest this:

 

<?php
function showimagesize($im){
    $Imagesize = getimagesize($_SERVER['DOCUMENT_ROOT']."/portfolio/images/".$im."");
    $width = $Imagesize[0] + 40; 
    $height = $Imagesize[1] + 40;
    echo   "<td><a href=\"/portfolio/images/$im\" onclick=\"NewWindow(this.href,'name','$width','$height','yes');return false\">$im</a> </td>";
}
showimagesize($rsEdit["ClientLogo"]);
?>

 

But then im not sure if that is what you want given your last post.

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.