• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 395
  • Last Modified:

PHP Tooltip (nearly there..)

Hi everyone I hope i find you all well.
Firstly, A HUGE THANK YOU to you AWESOMELY KIND PATIENT GURUS on here (you know who you are :>)) who helped me with this question on a previous post. This is a cut down non-spaghetti version of that, which i could not yet get working (most probably due to me being a bit 'slow', and not because of the skillful people who tried to help me on this). I think this time we will have better luck as Ive made some progress now (which is predominantly due to the ever-helpful brilliant minds on here :>))

I have a function guys that displays tooltips.
The function is named:    wz_tooltip_image
I call it by: wz_tooltip_image ($displaynamelink, $title)
I am calling this inside a WHILE LOOP, in order to display images from records in a mysql table.
So a call might look like below:

while ($row = mysql_fetch_object($rs)) {      
wz_tooltip_image($row->name_ent, $row->name_ent);
}
      
The problem I am having with this function is with the $stuffimage variable.

-----------------------------------------------------------------------------------
WHAT DOES WORK IN THE $stuffimage variable:
-----------------------------------------------------------------------------------
In the following, I have just placed part of $stuffimage (the important parts):

1) Sending a variable through a query string to image_fetcher.php: THIS WORKS
onmouseover=\"Tip('<img src=\'image_fetcher.php?id_ent=102\'>',

2) Hard coding the image name: THIS WORKS
onmouseover=\"Tip('<img src=\'cat.jpg\'>',

-----------------------------------------------------------------------------------
WHAT DOES NOT WORK BUT WHAT I NEED TO GET WORKING
-----------------------------------------------------------------------------------
Although the above 2 points work, I dont want to use these methods
in reality, since Im hard coding either the GET variable, or the image
I want to pull the image records from a mysql table, so I need to get point 1 above, which is:

onmouseover=\"Tip('<img src=\'image_fetcher.php?id_ent=102\'>',

which DOES WORK, to be slightly changed to push the $row->id_ent to image_fetcher.php

THE BELOW DOES NOT WORK, and errors with 'Unterminated string constant'
THIS IS THE ONLY PART I NEED TO GET WORKING.
onmouseover=\"Tip('<img src=\"imagefetcher.php?id_ent='.$row->id_ent.\'>',

The problem above is with how i am escaping the
?id_ent='.$row->id_ent

Any help on this I would be truly grateful.

Thank you everyone :>)






======================================================
FUNCTION wz_tooltip_image:
======================================================
function wz_tooltip_image ($displaynamelink, $title) {
 
$wz_tooltip_config_image = "
STICKY, true, 
FIX, [740,235], 
WIDTH, 870,  
HEIGHT, 565, 
BGCOLOR, 'black', 
TITLE, 'Image: $title', 
TITLEFONTCOLOR, '#FFC', 
TITLEBGCOLOR, '#664',  
EXCLUSIVE, false, 
CLICKSTICKY, true, 
CLICKCLOSE, false,
CLOSEBTN, true
"; 
 
$styleimage = "style=\"font-family:arial; font-size:xx-small; padding:0; margin:0; border:none;\"";
 
// The following 2 lines work for the variable '$stuffimage' ///////////////////////////////////////////////////////////////
 
// 1) SENDING A VARIABLE THROUGH A QUERY STRING TO IMAGE_FETCHER.PHP:
$stuffimage = "<a href=\"#\" $style onmouseover=\"Tip('<img src=\'image_fetcher.php?id_ent=102\'>',$wz_tooltip_config_image)\" onmouseout=\"UnTip()\">$displaynamelink</a>";
 
// 2) HARD CODING THE IMAGE NAME:
$stuffimage = "<a href=\"#\" $style onmouseover=\"Tip('<img src=\'cat.jpg\'>',$wz_tooltip_config_image)\" onmouseout=\"UnTip()\">$displaynamelink</a>";

Open in new window

0
Simon336697
Asked:
Simon336697
  • 11
  • 6
1 Solution
 
Marcus BointonCommented:
The wz library is now very old. You should take a look at more modern replacements like http://livepipe.net/control/window

This syntax should work fine (it's something you have tried above already) - it tested ok for me. The only problem I can see is that line breaks inside $wz_tooltip_config_image will probably break Internet Explorer as it doesn't handle white space properly.

$stuffimage = "<a href=\"#\" $style onmouseover=\"Tip('<img src=\'image_fetcher.php?id_ent=$row->id_ent\'>',$wz_tooltip_config_image)\" onmouseout=\"UnTip()\">$displaynamelink</a>";
0
 
Simon336697Author Commented:
hi Squinky,

Mate thanks so much for that...

With the $stuffimage you did above, i get the following....

http://localhost/dropdowndbpilot/pagination/paginationpilotdb/image_fetcher.php?id_ent=

0
 
Marcus BointonCommented:
Check that you don't have a line break in the middle of $row->id_ent
0
Technology Partners: 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!

 
Simon336697Author Commented:
Mate no line breaks.
0
 
Simon336697Author Commented:
Ive tried the following and it breaks..
$okay = "$row->id_ent";
<img src=\'image_fetcher.php?id_ent=\"$okay\"\'>'
0
 
Simon336697Author Commented:
This escaping in php is killing me :>)
0
 
Simon336697Author Commented:
This works:

onmouseover=\"Tip('<img src=\'image_fetcher.php?id_ent=102\'>'

but this doesnt:

onmouseover=\"Tip('<img src=\'image_fetcher.php?id_ent=$row->id_ent\'>'
0
 
Marcus BointonCommented:
Try:

var_dump($row->id_ent);

To confirm what is in that var.
0
 
Simon336697Author Commented:
Okay bud (thank u so much for your help :>)
I'll Be right back :>)
0
 
Simon336697Author Commented:
Output mate is:

string(3) "102"
0
 
Marcus BointonCommented:
That looks ok. Weird that it works for me. You could give this a go:

onmouseover=\"Tip('<img src=\'image_fetcher.php?id_ent={$row->id_ent}\'>'

or drop out of interpolation and concat it yourself:

onmouseover=\"Tip('<img src=\'image_fetcher.php?id_ent=".$row->id_ent."\'>'
0
 
Simon336697Author Commented:
Squinky, i wonder if it could be the following..

The function im defining has $stuffimage inside of it.

Im calling the function INSIDE a WHILE LOOP,  as follows:

while ($row = mysql_fetch_object($rs)) {      

wz_tooltip_image($row->name_ent, $row->name_ent);      


So im wondering if that is why $row->id_ent

is not being seen in the query string, because:

onmouseover=\"Tip('<img src=\'image_fetcher.php?id_ent=$row->id_ent\'>'

is defined in the function?

What i get is:

http://localhost/dropdowndbpilot/pagination/paginationpilotdb/image_fetcher.php?id_ent=

when using:

$stuffimage = "<a href=\"#\" $style onmouseover=\"Tip('<img src=\'image_fetcher.php?id_ent=$row->id_ent\'>',$wz_tooltip_config_image)\" onmouseout=\"UnTip()\">$displaynamelink</a>";

and the above is INSIDE the function, OUTSIDE the WHILE statement.

But, in the WHILE statement, i can do

var_dump($row->id_ent);      

and get the id_ent value.


0
 
Simon336697Author Commented:
Squinky, i tried both of your suggestions, and still get ?id_ent=

0
 
Simon336697Author Commented:
<<<<<<<<<<<<<<<<< MATE IT WORKS!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! >>>>>>>>>>>>>>>>>>>>>>

It was because my definition of $row->id_ent was INSIDE THE FUNCTION.

I changed the function to include a 3rd parameter as follows:

function wz_tooltip_image ($displaynamelink, $title, $showme) {

blah blah

onmouseover=\"Tip('<img src=\'image_fetcher.php?id_ent=$showme\'>',

}

then called it with:

wz_tooltip_image($row->name_ent, $row->name_ent, $row->id_ent);      

and it works!!!!!!!!!!!!!!!


MATE THANK YOU SO MUCH FOR YOUR KIND HELP!!

0
 
Marcus BointonCommented:
Well if $stuffimage is defined inside the function, it won't exist outside it. Similarly, if $row is defined outside the function then it won't be available inside it. Are you echoing $stuffimage inside or outside the function?
0
 
Marcus BointonCommented:
Dang, me too slow!
0
 
Simon336697Author Commented:
Thanks so much squinky you were on to it mate :>)
You guys on here are just incredible.
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!

  • 11
  • 6
Tackle projects and never again get stuck behind a technical roadblock.
Join Now