Jump to content

How To Add A Tooltip To An Image


sildona

Recommended Posts

I cannot figure out how to add this tooltip snippet

 




$tooltips = Array("Prison"=>"This word is word number 1", "Word2"=>"This word is word number 2");

$content = "Here are Word1 and Word2";
foreach ($tooltips as $word=>$tip){
   $content = preg_replace("/(".$word.")/", "<span title='".$tip."'>$1</span>", $content);
}
echo $content;

 

to the following image displayed from a database

 



echo "<img src='".$showimage."' height='200px' width='133px' />";

 

every time I try to call the variable $showimage in the tooltip, it comes out as a bunch of error messages and text. Any help would be greatly appreciated.

Link to comment
https://forums.phpfreaks.com/topic/269979-how-to-add-a-tooltip-to-an-image/
Share on other sites

From your code, I'm not really sure what you're having problems with. Maybe giving us the error messages would help, but I wrote to someone else adding a tooltip to an image with and without JS.

 

http://forums.phpfreaks.com/topic/269966-how-to-add-tooltip-for-image-displayed-from-database/

 

If that's the kind of tooltip you're talking about. It could be changed to fit about anything.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.