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
Share on other sites

I'm not understanding the question. I get that you want to put this into a function - do you want to pass it an argument -of what directory the image is in. You can't echo anything into a URL unless you wrote the URL

Can you please be more specific

Link to comment
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>';
}

?>

Link to comment
Share on other sites

i need to get the image width and height from the following fields and place the width and height into the url where the $width and $height variables are

 

ClientLogo

PortImage1

PortImage2

PortImage3

 

any better?

 

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.