Jump to content

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.