Solved

Building a PHP Function

Posted on 2008-10-20
6
196 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
Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

 
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

Independent Software Vendors: 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!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
MySQL limit and not so limited 13 41
Unwanted output from my query 5 42
Multi line FPDF footer: 3 28
How do I post more than 1 item to php backend 24 31
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 …
This article discusses four methods for overlaying images in a container on a web page
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
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…

733 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