Solved

Building a PHP Function

Posted on 2008-10-20
6
192 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
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Consider the following scenario: You are working on a website and make something great - something that lets the server work with information submitted by your users. This could be anything, from a simple guestbook to a e-Money solution. But what…
This article will explain how to display the first page of your Microsoft Word documents (e.g. .doc, .docx, etc...) as images in a web page programatically. I have scoured the web on a way to do this unsuccessfully. The goal is to produce something …
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…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

707 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now