happysunny
asked on
Tooltips
Hello all :)
I am trying to pull pictures from a database and put them into a table. I have created a mock website page of what I'm trying to accomplish.
http://www.hubcitydesigns.com/hubcity/jewelry2.php
On this page, you'll see 3 flowers. When you rollover the flowers, a tooltip comes up. It's so pretty :) Unfortunately, the tooltip remains the same on all 3 pictures and this is not so pretty!
So, does anyone know how to make the tooltip look like the thumbnail? I can assure you the pictures in the database are different, but the display is not.
Also, I am using this Dynamic Drive tooltip:
http://www.dynamicdrive.com/dynamicindex5/stickytooltip.htm
Thank you ahead of time :)
I am trying to pull pictures from a database and put them into a table. I have created a mock website page of what I'm trying to accomplish.
http://www.hubcitydesigns.com/hubcity/jewelry2.php
On this page, you'll see 3 flowers. When you rollover the flowers, a tooltip comes up. It's so pretty :) Unfortunately, the tooltip remains the same on all 3 pictures and this is not so pretty!
So, does anyone know how to make the tooltip look like the thumbnail? I can assure you the pictures in the database are different, but the display is not.
Also, I am using this Dynamic Drive tooltip:
http://www.dynamicdrive.com/dynamicindex5/stickytooltip.htm
Thank you ahead of time :)
Try this:
<?php
include ("dbinfo.php");
//count number of records
$result = mysql_query("SELECT * FROM products") or die
(mysql_error());
$num_rows = mysql_num_rows($result);
if(mysql_num_rows($result) == 0) {
echo "<font size=\"4\" face=\"Arial\"><center>No results were found.</center>";
$none="1";
}
//number you want to display per page
$page_rows=6;
//This tells us the page number of last page
$last=ceil($num_rows/$page_rows);
//determine results
//This checks to see if there's a page number. If not, it will set it to page 1.
if(isset($_GET['pagenum'])) {
$pagenum=$_GET['pagenum'];
}
else{
$pagenum=1;
}
$pagenum=(int)$pagenum;
if ($pagenum>$last)
{
$pagenum=$last;
}
if ($pagenum<1)
{
$pagenum=1;
}
$offset=($pagenum - 1) * $page_rows;
$a=1;
echo "<div id=\"mystickytooltip\" class=\"stickytooltip\">";
echo "<div style=\"padding:5px\">";
echo "<table width=\"100%\"style=\"FONT-SIZE: 11pt\" face=\"Arial\" align=center border=
\"1\" solid black; cellspacing=\"10\"> ";
echo "<tbody>";
echo "<tr>";
$sql="SELECT * FROM products LIMIT $offset, $page_rows";
$result=mysql_query($sql);
while ($row = mysql_fetch_assoc($result))
{
$regpic=$row["fileName"];
$regpic=htmlspecialchars($regpic);
$thumb=$row["fileNameT1"];
$thumb=htmlspecialchars($thumb);
if ($a<=3)
{
echo "<td width=\"25%\"><center><a href=\"\"><img src='$thumb' WIDTH=138 HEIGHT=117 border=
\"1\" data-tooltip=\"sticky$a\"></a><br>";
echo "<div id=\"sticky$a\" class=\"atip\">";
echo "<img src=\"$regpic\" width=\"300\" height=\"300\" />";
echo "</div>";
echo "</td>";
echo "</center>";
$a++;
}
else
{
echo "</tr><tr>";
echo "<td width=\"25%\"><center><a href=\"\"><img src='$thumb' WIDTH=138 HEIGHT=117 border=
\"1\" data-tooltip=\"sticky$a\"></a><br>";
echo "<div id=\"sticky$a\" class=\"atip\">";
echo "<img src=\"$regpic\" width=\"300\" height=\"300\" />";
echo "</div>";
echo "</td>";
echo "</center>";
$a=2;
}
}
echo "</tr></tbody></table>";
echo "</div>";
<div class="stickystatus"></div>
echo "</div>";
?>
ASKER
Hmmm...Now it shows a blank page :( Not sure why.
http://www.hubcitydesigns.com/hubcity/jewelry2.php
http://www.hubcitydesigns.com/hubcity/jewelry2.php
Give a different ID for each of the DIVs for each iteration. Concatenate the $a variable to the name... couple of places...
echo "<td width=\"25%\"><center><a href=\"\"><img src='$thumb' WIDTH=138 HEIGHT=117 border=\"1\" data-tooltip=\"sticky1\"></a><br>";
echo "<div id=\"sticky1\" class=\"atip\">";
Currently, you are effectively replacing the content of the DIV on every iteration of the loop.
echo "<td width=\"25%\"><center><a href=\"\"><img src='$thumb' WIDTH=138 HEIGHT=117 border=\"1\" data-tooltip=\"sticky1\"></a><br>";
echo "<div id=\"sticky1\" class=\"atip\">";
Currently, you are effectively replacing the content of the DIV on every iteration of the loop.
ASKER
I see...I tried it out, but it seems the last 2 tooltips are missing the pictures now. I'm getting excited about being closer to a solution, though :)
http://www.hubcitydesigns.com/hubcity/jewelry2.php
Hmmmm...
http://www.hubcitydesigns.com/hubcity/jewelry2.php
Hmmmm...
<?php
include ("dbinfo.php");
//count number of records
$result = mysql_query("SELECT * FROM products") or die
(mysql_error());
$num_rows = mysql_num_rows($result);
if(mysql_num_rows($result) == 0) {
echo "<font size=\"4\" face=\"Arial\"><center>No results were found.</center>";
$none="1";
}
//number you want to display per page
$page_rows=6;
//This tells us the page number of last page
$last=ceil($num_rows/$page_rows);
//determine results
//This checks to see if there's a page number. If not, it will set it to page 1.
if(isset($_GET['pagenum'])) {
$pagenum=$_GET['pagenum'];
}
else{
$pagenum=1;
}
$pagenum=(int)$pagenum;
if ($pagenum>$last)
{
$pagenum=$last;
}
if ($pagenum<1)
{
$pagenum=1;
}
$offset=($pagenum - 1) * $page_rows;
$a=1;
echo "<table width=\"100%\"style=\"FONT-SIZE: 11pt\" face=\"Arial\" align=center border=
\"1\" solid black; cellspacing=\"10\"> ";
echo "<tbody>";
echo "<tr>";
$sql="SELECT * FROM products LIMIT $offset, $page_rows";
$result=mysql_query($sql);
while ($row = mysql_fetch_assoc($result))
{
$regpic=$row["fileName"];
$regpic=htmlspecialchars($regpic);
$thumb=$row["fileNameT1"];
$thumb=htmlspecialchars($thumb);
if ($a<=3)
{
echo "<td width=\"25%\"><center><a href=\"\"><img src='$thumb' WIDTH=138 HEIGHT=117 border=
\"1\" data-tooltip=\"sticky$a\"></a><br>";
echo "<div id=\"mystickytooltip\" class=\"stickytooltip\">";
echo "<div style=\"padding:5px\">";
echo "<div id=\"sticky$a\" class=\"atip\">";
echo "<img src=\"$regpic\" width=\"300\" height=\"300\" />";
echo "</div>";
echo "</div>";
echo "</div>";
echo "</td>";
echo "</center>";
$a++;
}
else
{
echo "</tr><tr>";
echo "<td width=\"25%\"><center><a href=\"\"><img src='$thumb' WIDTH=138 HEIGHT=117 border=
\"1\" data-tooltip=\"sticky$a\"></a><br>";</a><br>";
echo "<div id=\"mystickytooltip\" class=\"stickytooltip\">";
echo "<div style=\"padding:5px\">";
echo "<div id=\"sticky$a\" class=\"atip\">";
echo "<img src=\"$regpic\" width=\"300\" height=\"300\" />";
echo "</div>";
echo "</div>";
echo "</div>";
echo "</td>";
echo "</center>";
$a=2;
}
}
echo "</tr></tbody></table>";
?>
I just looked at the original website
http://www.dynamicdrive.com/dynamicindex5/stickytooltip.htm
The only mistake now u may be making is that your iteration is creating multiple DIVs for "mystickytooltip"... whereas it should be creating just ONE.
Hence, take the following code out of the loop and put it outside.
echo "<div id=\"mystickytooltip\" class=\"stickytooltip\">";
Look at the example from that site again....
http://www.dynamicdrive.com/dynamicindex5/stickytooltip.htm
The only mistake now u may be making is that your iteration is creating multiple DIVs for "mystickytooltip"... whereas it should be creating just ONE.
Hence, take the following code out of the loop and put it outside.
echo "<div id=\"mystickytooltip\" class=\"stickytooltip\">";
Look at the example from that site again....
<div id="mystickytooltip" class="stickytooltip">
<div style="padding:5px">
<div id="sticky1">
Sticky Tooptip 1 content here...
</div>
<div id="sticky2">
Sticky Tooptip 2 content here...
</div>
<div id="sticky3">
Sticky Tooptip 3 content here...
</div>
</div>
<div class="stickystatus"></div>
</div>
Your output should look something like this... take cue form it
<DIV STYLE=" position:absolute; top:170px; left:380px; width:750px; height:450px; z-index:938;">
<table width="100%" style="FONT-SIZE: 11pt" face="Arial" align=center border="1" solid black; cellspacing="10">
<tbody>
<tr>
<td width="25%">
<center>
<a href="">
<img src='../hubcity/testpics/yellowflower.jpg' WIDTH=138 HEIGHT=117 border="1" data-tooltip="sticky1">
</a>
</td>
</center>
<td width="25%">
<center>
<a href="">
<img src='../hubcity/testpics/pinkflower.jpg' WIDTH=138 HEIGHT=117 border="1" data-tooltip="sticky2">
</a>
</td>
</center>
<td width="25%">
<center>
<a href="">
<img src='../hubcity/testpics/whiteflower.jpg' WIDTH=138 HEIGHT=117 border="1" data-tooltip="sticky3">
</a>
</td>
</center>
</tr>
</tbody>
</table>
</DIV>
<div id="mystickytooltip" class="stickytooltip">
<div id="sticky1" class="atip">
<img src="../hubcity/testpics/yellowflower.jpg" width="300" height="300"/>
</div>
<div id="sticky2" class="atip">
<img src="../hubcity/testpics/pinkflower.jpg" width="300" height="300"/>
</div>
<div id="sticky3" class="atip">
<img src="../hubcity/testpics/whiteflower.jpg" width="300" height="300"/>
</div>
</div>
ASKER
Okay, but that takes me back to jmatix's code that leaves an empty page, unless I'm doing it wrong?
http://www.hubcitydesigns.com/hubcity/jewelry2.php
On line 69, does that div need to be elsewhere or is that what the problem may be?
http://www.hubcitydesigns.com/hubcity/jewelry2.php
On line 69, does that div need to be elsewhere or is that what the problem may be?
<?php
include ("dbinfo.php");
//count number of records
$result = mysql_query("SELECT * FROM products") or die
(mysql_error());
$num_rows = mysql_num_rows($result);
if(mysql_num_rows($result) == 0) {
echo "<font size=\"4\" face=\"Arial\"><center>No results were found.</center>";
$none="1";
}
//number you want to display per page
$page_rows=6;
//This tells us the page number of last page
$last=ceil($num_rows/$page_rows);
//determine results
//This checks to see if there's a page number. If not, it will set it to page 1.
if(isset($_GET['pagenum'])) {
$pagenum=$_GET['pagenum'];
}
else{
$pagenum=1;
}
$pagenum=(int)$pagenum;
if ($pagenum>$last)
{
$pagenum=$last;
}
if ($pagenum<1)
{
$pagenum=1;
}
$offset=($pagenum - 1) * $page_rows;
$a=1;
echo "<div id=\"mystickytooltip\" class=\"stickytooltip\">";
echo "<div style=\"padding:5px\">";
echo "<table width=\"100%\"style=\"FONT-SIZE: 11pt\" face=\"Arial\" align=center border=
\"1\" solid black; cellspacing=\"10\"> ";
echo "<tbody>";
echo "<tr>";
$sql="SELECT * FROM products LIMIT $offset, $page_rows";
$result=mysql_query($sql);
while ($row = mysql_fetch_assoc($result))
{
$regpic=$row["fileName"];
$regpic=htmlspecialchars($regpic);
$thumb=$row["fileNameT1"];
$thumb=htmlspecialchars($thumb);
if ($a<=3)
{
echo "<td width=\"25%\"><center><a href=\"\"><img src='$thumb' WIDTH=138 HEIGHT=117 border=
\"1\" data-tooltip=\"sticky$a\"></a><br>";
echo "<div id=\"sticky$a\" class=\"atip\">";
echo "<img src=\"$regpic\" width=\"300\" height=\"300\" />";
echo "</div>";
echo "</td>";
echo "</center>";
$a++;
}
else
{
echo "</tr><tr>";
echo "<td width=\"25%\"><center><a href=\"\"><img src='$thumb' WIDTH=138 HEIGHT=117 border=
\"1\" data-tooltip=\"sticky$a\"></a><br>";</a><br>";
echo "<div id=\"sticky$a\" class=\"atip\">";
echo "<img src=\"$regpic\" width=\"300\" height=\"300\" />";
echo "</div>";
echo "</td>";
echo "</center>";
$a=2;
}
}
echo "</tr></tbody></table>";
echo "</div>";
echo "<div class=\"stickystatus\"></div>";
echo "</div>";
?>
Please try to mimic the above output. You may need two loops to get your desired output (through it can be done with just one). Please try with 2 loops first which should be easy.
ASKER
I am afraid this is just one set of pictures that are coming out of the database. Some pages have up to 20 pictures that I use pagination to put in order.
I am not confident in my ability to add a second while loop. Can you give me some advice on how that would need to be added?
Thank you :)
I am not confident in my ability to add a second while loop. Can you give me some advice on how that would need to be added?
Thank you :)
ASKER
I tried adding a second loop, but it didn't work. If you really think the $a should work, I'd rather stick with trying to figure that out. Really, I'm unsure why the code doesn't work.
It seems when I take the
part and keep it into the loop, the images actually show up. When I put it outside the loop, everything disappears. I'm unsure where to go from here.
It seems when I take the
echo "<div id=\"mystickytooltip\" class=\"stickytooltip\">";
echo "<div style=\"padding:5px\">";
part and keep it into the loop, the images actually show up. When I put it outside the loop, everything disappears. I'm unsure where to go from here.
I am not sure if you have already figured this out. The problem is that the thumbnails should be out the <div id="mystickytooltip"> block. Otherwise it will be hidden by default. I tried the code below and it worked. I build the thumbnail HTML inside the loop, but print it after exiting the loop.
$htm = "";
while ($row = mysql_fetch_assoc($result))
{
$regpic=$row["fileName"];
$regpic=htmlspecialchars($regpic);
$thumb=$row["fileNameT1"];
$thumb=htmlspecialchars($thumb);
if ($a<=3)
{
$htm .= "<a href=\"\"><img src='$thumb' WIDTH=138 HEIGHT=117 border=
\"1\" data-tooltip=\"sticky$a\"></a><br>";
echo "<td width=\"25%\"><center><div id=\"sticky$a\" class=\"atip\">";
echo "<img src=\"$regpic\" width=\"300\" height=\"300\" />";
echo "</div>";
echo "</td>";
echo "</center>";
$a++;
}
else
{
echo "</tr><tr>";
$htm .= "<a href=\"\"><img src='$thumb' WIDTH=138 HEIGHT=117 border=
\"1\" data-tooltip=\"sticky$a\"></a><br>";
echo "<td width=\"25%\"><center><div id=\"sticky$a\" class=\"atip\">";
echo "<img src=\"$regpic\" width=\"300\" height=\"300\" />";
echo "</div>";
echo "</td>";
echo "</center>";
$a=2;
}
$c++;
}
echo "</tr></tbody></table>";
echo "</div>";
echo "<div class='stickystatus'></div>";
echo "</div>";
echo $htm;
ASKER
Yes, as long as it is inside that <div> it wouldn't work. I worked in your code instead and it still isn't working.
http://www.hubcitydesigns.com/hubcity/jewelry2.php
http://www.hubcitydesigns.com/hubcity/jewelry2.php
<?php
include ("dbinfo.php");
//count number of records
$result = mysql_query("SELECT * FROM products") or die
(mysql_error());
$num_rows = mysql_num_rows($result);
if(mysql_num_rows($result) == 0) {
echo "<font size=\"4\" face=\"Arial\"><center>No results were found.</center>";
$none="1";
}
//number you want to display per page
$page_rows=6;
//This tells us the page number of last page
$last=ceil($num_rows/$page_rows);
//determine results
//This checks to see if there's a page number. If not, it will set it to page 1.
if(isset($_GET['pagenum'])) {
$pagenum=$_GET['pagenum'];
}
else{
$pagenum=1;
}
$pagenum=(int)$pagenum;
if ($pagenum>$last)
{
$pagenum=$last;
}
if ($pagenum<1)
{
$pagenum=1;
}
$offset=($pagenum - 1) * $page_rows;
$a=1;
echo "<table width=\"100%\"style=\"FONT-SIZE: 11pt\" face=\"Arial\" align=center border=
\"1\" solid black; cellspacing=\"10\"> ";
echo "<tbody>";
echo "<tr>";
$htm="";
$sql="SELECT * FROM products LIMIT $offset, $page_rows";
$result=mysql_query($sql);
while ($row = mysql_fetch_assoc($result))
{
$regpic=$row["fileName"];
$regpic=htmlspecialchars($regpic);
$thumb=$row["fileNameT1"];
$thumb=htmlspecialchars($thumb);
if ($a<=3)
{
$htm .= "<a href=\"\"><img src='$thumb' WIDTH=138 HEIGHT=117 border=\"1\" data-tooltip=
\"sticky$a\"></a><br>";
echo "<td width=\"25%\"><center><div id=\"sticky$a\" class=\"atip\">";
echo "<img src=\"$regpic\" width=\"300\" height=\"300\" />";
echo "</div>";
echo "</td>";
echo "</center>";
$a++;
}
else
{
echo "</tr><tr>";
$htm .= "<a href=\"\"><img src='$thumb' WIDTH=138 HEIGHT=117 border=\"1\" data-tooltip=
\"sticky$a\"></a><br>";
echo "<td width=\"25%\"><center><div id=\"sticky$a\" class=\"atip\">";
echo "<img src=\"$regpic\" width=\"300\" height=\"300\" />";
echo "</div>";
echo "</td>";
echo "</center>";
$a=2;
}
$c++;
}
echo "</tr></tbody></table>";
echo "</div>";
echo "<div class='stickystatus'></div>";
echo "</div>";
echo $htm;
?>
ASKER
Oops-On line 92 of my code, is that supposed to a++? I changed that, but now it shows 2 to a line instead of 3. Regardless, it isn't showing the tooltips at all. Hmmm...Do you know of a simpler code I could use?
I added $c++ as my counter variable since for testing I was not pulling image filenames from database. Ignore that line. Can you post the generated HTML from your browser (view source)?
ASKER
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<script type="text/javascript" src="stickytooltip.js">
/***********************************************
* Sticky Tooltip script- (c) Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for this script and 100s more
***********************************************/
</script>
<link rel="stylesheet" type="text/css" href="stickytooltip.css" />
</head>
<html>
<body>
<DIV STYLE=" position:absolute; top:170px; left:380px; width:750px; height:450px; z-index:938;">
<table width="100%"style="FONT-SIZE: 11pt" face="Arial" align=center border=
"1" solid black; cellspacing="10"> <tbody><tr><td width="25%"><center><div id="sticky1" class="atip"><img src="../hubcity/testpics/yellowflower.jpg" width="300" height="300" /></div></td></center><td width="25%"><center><div id="sticky2" class="atip"><img src="../hubcity/testpics/pinkflower.jpg" width="300" height="300" /></div></td></center><td width="25%"><center><div id="sticky3" class="atip"><img src="../hubcity/testpics/whiteflower.jpg" width="300" height="300" /></div></td></center></tr></tbody></table></div><div class='stickystatus'></div></div><a href=""><img src='../hubcity/testpics/yellowflower.jpg' WIDTH=138 HEIGHT=117 border="1" data-tooltip="sticky1"></a><br><a href=""><img src='../hubcity/testpics/pinkflower.jpg' WIDTH=138 HEIGHT=117 border="1" data-tooltip="sticky2"></a><br><a href=""><img src='../hubcity/testpics/whiteflower.jpg' WIDTH=138 HEIGHT=117 border="1" data-tooltip="sticky3"></a><br> </DIV>
</body>
</html>
I don't see a <div id="mystickytooltip" class="stickytooltip"> </div> enclosing the tooltip images. When I add that <div> it works. See my test HTML below:
<body>
<div id="mystickytooltip" class="stickytooltip">
<DIV STYLE=" position:absolute; top:170px; left:380px; width:750px; height:450px; z-index:938;">
<table width="100%"style="FONT-SIZE: 11pt" face="Arial" align=center border="1" solid black; cellspacing="10">
<tbody>
<tr>
<td width="25%">
<center>
<div id="sticky1" class="atip">
<img src="../images/Bluehills.jpg" width="300" height="300" />
</div></td>
</center>
<td width="25%">
<center>
<div id="sticky2" class="atip">
<img src="../images/Sunset.jpg" width="300" height="300" />
</div>
</td>
</center>
<td width="25%">
<center>
<div id="sticky3" class="atip">
<img src="../images/Waterlilies.jpg" width="300" height="300" />
</div>
</td>
</center>
</tr>
</tbody>
</table>
</div>
<div class='stickystatus'></div>
</div>
</div>
<a href="">
<img src='../images/Bluehills.jpg' WIDTH=138 HEIGHT=117 border="1" data-tooltip="sticky1"></a><br>
<a href="">
<img src='../images/Sunset.jpg' WIDTH=138 HEIGHT=117 border="1" data-tooltip="sticky2"></a><br>
<a href=""><img src='../images/Waterlilies.jpg' WIDTH=138 HEIGHT=117 border="1" data-tooltip="sticky3"></a><br> </DIV>
</body>
ASKER
Beautiful! It works! However, just a few more questions about it. It is now showing the images vertical instead of 3 across. And when you rollover it, there seems to be boxes on the sides of them. Looking over my code, I'm unsure exactly where this is coming from. Any ideas on how to fix it?
I'm getting excited!
Thanks!
I'm getting excited!
Thanks!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you! Works like a charm! And it's my birthday today :) Double the fun :)
To bring the tooltips closer to the thumbnails adjust the top and left positions of the enclosing <DIV>. You can even put -ve values as:
<DIV STYLE="position:absolute; top:0px; left:-50px; width:750px; height:450px; z-index:938;">
<DIV STYLE="position:absolute; top:0px; left:-50px; width:750px; height:450px; z-index:938;">
ASKER
Awesome. I'll keep that in mind :) Thank you!
Happy B'day. Enjoy!!!
ASKER
Thank you :) It's the big 3-Oh my god! :) Enjoying every moment of it!
ASKER
Open in new window