jesushax Posted June 9, 2008 Share Posted June 9, 2008 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> Quote Link to comment https://forums.phpfreaks.com/topic/109367-solved-creating-functions/ Share on other sites More sharing options...
hansford Posted June 9, 2008 Share Posted June 9, 2008 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 Quote Link to comment https://forums.phpfreaks.com/topic/109367-solved-creating-functions/#findComment-560963 Share on other sites More sharing options...
Guest Xanza Posted June 9, 2008 Share Posted June 9, 2008 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>'; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/109367-solved-creating-functions/#findComment-560968 Share on other sites More sharing options...
jesushax Posted June 9, 2008 Author Share Posted June 9, 2008 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? Quote Link to comment https://forums.phpfreaks.com/topic/109367-solved-creating-functions/#findComment-560969 Share on other sites More sharing options...
GingerRobot Posted June 9, 2008 Share Posted June 9, 2008 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. Quote Link to comment https://forums.phpfreaks.com/topic/109367-solved-creating-functions/#findComment-560970 Share on other sites More sharing options...
jesushax Posted June 9, 2008 Author Share Posted June 9, 2008 i think thats what im after there where $im is the name of the file that i want to check how do i use it? cheers Quote Link to comment https://forums.phpfreaks.com/topic/109367-solved-creating-functions/#findComment-560972 Share on other sites More sharing options...
jesushax Posted June 9, 2008 Author Share Posted June 9, 2008 wait i see now, ill try it out i think thats what i was after Quote Link to comment https://forums.phpfreaks.com/topic/109367-solved-creating-functions/#findComment-560974 Share on other sites More sharing options...
jesushax Posted June 9, 2008 Author Share Posted June 9, 2008 works perfectly thankyou very much Quote Link to comment https://forums.phpfreaks.com/topic/109367-solved-creating-functions/#findComment-560976 Share on other sites More sharing options...
hansford Posted June 9, 2008 Share Posted June 9, 2008 thats why Ben has all of them stars after his name Quote Link to comment https://forums.phpfreaks.com/topic/109367-solved-creating-functions/#findComment-560980 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.