Solved

Building a PHP Function

Posted on 2008-10-20
6
197 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
[X]
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
  • 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to dynamically set the form action using jQuery.

691 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