Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Building a PHP Function

Posted on 2008-10-20
6
195 Views
Last Modified: 2012-05-05
Hi guys hope you are all well.
Guys im having issues trying to make the following code into a php function.

For example, the following works fine:

<a href="#" onmouseover="Tip('Some text', STICKY, true, EXCLUSIVE, false, CLICKSTICKY, true, CLOSEBTN, true)" onmouseout="UnTip()">Homepage </a><br>      

What Im trying to do is the following....

Hope you guys can assist.


function wz_tooltip_text ($text, $displaynamelink) {
 
	$wz_tooltip_config_text = "STICKY, true, EXCLUSIVE, false, CLICKSTICKY, true, CLOSEBTN, true";	
	
print <<<HERE
<a href="#" onmouseover="Tip('<?php echo {$text}; ?>',<?php echo {$wz_tooltip_config_text}; ?>)" onmouseout="UnTip()"><<?php echo {$displaynamelink}; ?>></a>	
HERE;
}

Open in new window

0
Comment
Question by:Simon336697
  • 3
  • 3
6 Comments
 
LVL 17

Expert Comment

by:psimation
ID: 22756874
function wz_tooltip_text ($text, $displaynamelink) {
 
        $wz_tooltip_config_text = "STICKY, true, EXCLUSIVE, false, CLICKSTICKY, true, CLOSEBTN, true";  
       
$stuff = "<a href=\"#\" onmouseover=\"Tip('$text',$wz_tooltip_config_text)\" onmouseout=\"UnTip()\"><$displaynamelink></a>";

return $stuff;

}
0
 
LVL 1

Author Comment

by:Simon336697
ID: 22757065
Hi psimation..
Thank you mate...still having issues with it.

0
 
LVL 17

Expert Comment

by:psimation
ID: 22757110
What issues are you having? Errors?

0
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 1

Author Comment

by:Simon336697
ID: 22757164
Mate thank you for your help.

It works if i do the following and not use RETURN (I dont know why this is).

I can then call it as follows....

<?php wz_tooltip_text("hi there","Go there"); ?>

The above works fine, but I need to go one step further psim and make the arguments variables like below....

Im trying to retrieve records from a mysql table with

while ($row = mysql_fetch_object($rs)) {
print $row->name_ent;
etc

so

im hoping to do as below...

while ($row = mysql_fetch_object($rs)) {
<?php wz_tooltip_text("< print $row->id_ent;","print $row->name_ent;"); ?>




function wz_tooltip_text ($text, $displaynamelink) {
 
        $wz_tooltip_config_text = "STICKY, true, EXCLUSIVE, false, CLICKSTICKY, true, CLOSEBTN, true";   
			$stuff = "<a href=\"#\" onmouseover=\"Tip('$text',$wz_tooltip_config_text)\" onmouseout=\"UnTip()\">$displaynamelink</a>";
echo $stuff;
}

Open in new window

0
 
LVL 17

Accepted Solution

by:
psimation earned 500 total points
ID: 22757239
while ($row = mysql_fetch_object($rs)) {
<?php wz_tooltip_text("< print $row->id_ent;","print $row->name_ent;"); ?>

should be this?

<?php
while ($row = mysql_fetch_object($rs)) {
wz_tooltip_text($row->id_ent,$row->name_ent);
}
?>
0
 
LVL 1

Author Comment

by:Simon336697
ID: 22757317
Thats great thank you so much psimation................CHAMPION !!!!
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question