473,382 Members | 1,791 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

How to show dynamic popup on mouseover of thumbnail

I’m writing because I need help with a problem that has been frustrating me for about a week now and I am desperate for a solution. I recently built my first website using PHP and MySQL and am trying to add feature/function that will pop up a photo thumbnail when the mouse is placed over a certain field in a table. I still want the field to link to the place it goes, just when you hover over it a thumbnail showing the image of the product appears e.g. a catalogue list that links to more information about a product but you can see the product from the catalogue list by hovering over a section (I hope this makes sense).

The code I have written so far to populate the table looks like:


Expand|Select|Wrap|Line Numbers
  1. $query=" SELECT * FROM table";
  2. $result=mysqli_query($cxn,$query)or die("Couldn't execute query.");
  3.  
  4.   while($row = mysqli_fetch_assoc($result))            
  5.   {
  6.     $f_price = number_format($row['price'],2);
  7.  
  8.  echo "<table class='Products' cellspacing='0'
  9.                width='100%'>";
  10.    echo "<tr><th class='head'>Product ID</th><th class='head'>P_type</th><th class='head'>Price</th>
  11.    </tr>\n";  
  12.     echo "<tr class= 'trow'>\n";
  13.     echo " <td class= 'item'><a href='result.php?product_ID={$row['product_ID']}'>{$row['product_ID']}</a></td>\n";
  14.     echo " <td class= 'item'><a href='result.php?product_ID={$row['product_ID']}'>{$row['P_type']}</a></td>\n";
  15.     echo " <td class= 'item'><a href='result.php?product_ID={$row['product_ID']}'>$f_price</a></td>\n";
  16.  
  17. }
  18. echo "</table>\n"; 
  19.  
What I am after is a photo thumbnail to popup showing the product when you hover over the Product_ID field. The photos are kept in a folder on the server with the photo’s name stored in the SQL db. If someone could help me with a way to do this and some code it really would be a big help. I’ve done a lot of reading on the internet over the past week and I seems that a lot of people are looking for the same sort of thing but no one can provide an accurate solution. Please help!!
May 25 '10 #1
1 4676
I have been trying to fix this problem myself but I just can’t seem to get it right. I can make an image popup but it seems to be the same image for every product, I want them to change as you hover over the different product ID’s. This is what I have:

Expand|Select|Wrap|Line Numbers
  1.  <script type="text/javascript" >
  2.     function ShowPopup(hoveritem)
  3.     {
  4.         hp = document.getElementById("hoverpopup");
  5.  
  6.         // Set popup to visible
  7.         hp.style.top = hoveritem.offsetTop + 18;
  8.         hp.style.left = hoveritem.offsetLeft + 20;
  9.  
  10.         hp.style.visibility = "Visible";
  11.     }
  12.  
  13.     function HidePopup()
  14.     {
  15.         hp = document.getElementById("hoverpopup");
  16.         hp.style.visibility = "Hidden";    
  17.     }
  18. </script>
  19. $query=" SELECT * FROM table";   $result=mysqli_query($cxn,$query)or die("Couldn't execute query.");
  20.  
  21. while($row = mysqli_fetch_assoc($result)) 
  22. {
  23. $f_price = number_format($row['price'],2);
  24. $product= {$row['product_ID']}
  25.  
  26. echo "<table class='Products' cellspacing='0'
  27. width='100%'>";
  28. echo "<tr><th class='head'>Product ID</th><th class='head'>P_type</th><th class='head'>Price</th>
  29. </tr>\n"; 
  30. echo "<tr class= 'trow'>\n";
  31. echo " <td class= 'item'><a href='result.php?product_ID={$row['product_ID']} id='hoverover' style='cursor:important;' onMouseOver='ShowPopup(this);' onMouseOut='HidePopup();'>{$row['unit_ID']}</a></td>\n";
  32. echo " <td class= 'item'><a href='result.php?product_ID={$row['product_ID']}'>{$row['P_type']}</a></td>\n";
  33. echo " <td class= 'item'><a href='result.php?product_ID={$row['product_ID']}'>$f_price</a></td>\n";
  34.  
  35. }
  36. echo "</table>\n";
  37. </div>
  38.  
  39.   <div id="hoverpopup" style="visibility:hidden; position:absolute; top:120px; left:1px; width: 169px; height: 140px;">
  40.  
  41. <?php
  42.  $query=" SELECT * FROM bikes WHERE product_ID=$product ";
  43. $result=mysqli_query($cxn,$query)or die("Couldn't execute query.");
  44. $row = mysqli_fetch_assoc($result);
  45. echo "<table>\n";
  46.      echo "<tr><td><a href='../photos/{$row['pix']}' border='1'>
  47.     <img src='../photos/{$row['pix']}' border='1' width='200' height='200' />$unit</tr>\n";
  48.  
  49.  
  50. echo "</table>\n";
  51. ?>
  52. </div>    
  53.  
Can someone please help me? Thanks in advance.
May 26 '10 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: empiresolutions | last post by:
Hello fellow code junkies, I am using the "Ajax dynamic list" http://dhtmlgoodies.com/index.html?whichScript=ajax-dynamic-list and i think its the best out there. I have found a compatibility...
1
by: Samuel Rhodes | last post by:
hi i am using a ajax modal popup to allow the user to search an item and select the required item from the list. whenever i try to search the item, which causes a post back....the modal popup...
1
by: JohnnieTech | last post by:
I am using some javascript/ajax to load content into a main div. The problem I am running into is that it will work in IE but not in FF. In FF I don't get any sort of load at all. I have a 1...
1
by: satishr23 | last post by:
Hi, I am having some problems with handling cross domain requests in javascript/ajax and would really appreciate any help. My client has a javascript file which he includes in his HTML...
1
by: veer165 | last post by:
I have a list of items... And i want a little thumbnail of each item to be displayed when the mouse is over a particular text ... Say if i have a list of fruits i want an apple thumbnail on the...
3
by: SE.Computerguy | last post by:
I am trying to use the AJAX modal popup on a click event from a gridview. Any ideas on implementing this? The AJAX control is looking for a TargetControlID that will trigger the popup but the...
2
by: papillonhn | last post by:
hi everybody. I have a question: Doesn't Ajax for .net have xmlserializer class in javascript? It just have Sys.Serialization.JavaScriptSerializer library to use for Json. I need a...
6
by: dasrasmikant | last post by:
Hello, I am new in Ajax. I want to create Ajax dynamic list with ASP and XML. can anybody will help me regarding This. Thanks in advance..
4
by: fran_j_diaz | last post by:
Hi, I have a page with an Ajax modal popup. I would like to know when my Modal popup is opened, my page still able to modify. Is it possible ? (I use Visual Studio 2005, c# )
61
anfetienne
by: anfetienne | last post by:
could anyone tell me the mthod to use javascript/ajax to post to a sql database? or could someone point me to a tutorial?
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.