473,385 Members | 1,325 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,385 software developers and data experts.

php onmouseover help please

I have a js script inside php code that is connected to mysql, the php code is listing the results from the query then, the onmouseover function is supposed to show the description of the title for that specific title, however, the mouseover is displaying all the descriptions for every title. Also, will you let me know if I have code in here that is not needed? I'm very new to php/js

Expand|Select|Wrap|Line Numbers
  1. <script type="text/javascript" language="JavaScript">
  2. <!-- Copyright 2006,2007 Bontrager Connection, LLC
  3. // http://bontragerconnection.com/ and http://www.willmaster.com/
  4. // Version: July 28, 2007
  5. var cX = 0; var cY = 0; var rX = 0; var rY = 0;
  6. function UpdateCursorPosition(e){ cX = e.pageX; cY = e.pageY;}
  7. function UpdateCursorPositionDocAll(e){ cX = event.clientX; cY = event.clientY;}
  8. if(document.all) { document.onmousemove = UpdateCursorPositionDocAll; }
  9. else { document.onmousemove = UpdateCursorPosition; }
  10. function AssignPosition(d) {
  11. if(self.pageYOffset) {
  12.  
  13. rX = self.pageXOffset;
  14.  
  15. rY = self.pageYOffset;
  16. }
  17. else if(document.documentElement && document.documentElement.scrollTop) {
  18.  
  19. rX = document.documentElement.scrollLeft;
  20.  
  21. rY = document.documentElement.scrollTop;
  22. }
  23. else if(document.body) {
  24.  
  25. rX = document.body.scrollLeft;
  26.  
  27. rY = document.body.scrollTop;
  28.  
  29. }
  30. if(document.all) {
  31.  
  32. cX += rX;
  33.  
  34. cY += rY;
  35. }
  36. d.style.left = (cX+10) + "px";
  37. d.style.top = (cY+10) + "px";
  38. }
  39. function HideContent(d) {
  40. if(d.length < 1) { return; }
  41. document.getElementById(d).style.display = "none";
  42. }
  43. function ShowContent(d) {
  44. if(d.length < 1) { return; }
  45. var dd = document.getElementById(d);
  46. AssignPosition(dd);
  47. dd.style.display = "block";
  48. }
  49. function ReverseContentDisplay(d) {
  50. if(d.length < 1) { return; }
  51. var dd = document.getElementById(d);
  52. AssignPosition(dd);
  53. if(dd.style.display == "none") { dd.style.display = "block"; }
  54. else { dd.style.display = "none"; }
  55. }
  56. //-->
  57. </script>
  58. <html>
  59. <head><title>Community in Alabama</title></head>
  60. <body>
  61. <table>
  62. <tr><td valign="top" height="100%" style="width: 183px" align="center">
  63.         <a href="http://bytes.com/Alabama/Auburn/index.htm">EverybodysList<p style="margin-top: 0">Auburn</p></a>
  64.         <a href="http://bytes.com/submit/post.php" target="_blank">Post to Artists</a>
  65.         <p><a href="http://bytes.com/account.htm">My Account</a></p>
  66.         <p><a href="http://bytes.com/terms.htm">Terms of Use</a></p>
  67.         <p><a href="http://bytes.com/scams.htm">About Scams</a></p>
  68.         <p><a href="http://bytes.com/feedback.htm">Contact Us</a></p>
  69.         <hr>
  70.         <img src="http://bytes.com/images/alabama.gif" alt="Alabama Flag" width="150" height="150">
  71.         <td valign="top"><font color="red">All Alabama</font><span style="visibility: hidden"> <a href=../../Auburn/Community/Al/tocprot.htm>Auburn</a>
  72.         <a href="http://bytes.com/Birmingham/Community/Al/tocproto.htm">Birmingham</a> 
  73.         <a href="http://bytes.com/Columbus/Community/Al/tocproto.htm">Columbus</a> 
  74. <a href="http://bytes.com/Dothan/Community/Al/tocproto.htm">Dothan</a> 
  75.         <a href="http://bytes.com/Florence/Community/Al/tocproto.htm">Florence</a> 
  76.         <a href="http://bytes.com/Gadsen/Community/Al/tocproto.htm">Gadsen</a> 
  77. <a href="http://bytes.com/Huntsville/Community/Al/tocproto.htm">Huntsville</a> 
  78.         <a href="http://bytes.com/Mobile/Community/Al/tocproto.htm">Mobile</a> 
  79.         <a href="http://bytes.com/Montgomery/Community/Al/tocproto.htm">Montgomery</a> 
  80. <a href="http://bytes.com/Tuscaloosa/Community/Al/tocproto.htm">Tuscaloosa</a></span>
  81. <?php 
  82. $user = ('account');
  83. $pass = ('account');
  84. $host = ('localhost');
  85. $link = mysql_connect('localhost', 'account', 'account'); 
  86. if (!$link) { 
  87.     die('Could not connect: ' . mysql_error()); 
  88. mysql_select_db("user", $link);
  89.  
  90. //Search criteria
  91. ?>
  92. <form action=search.php action=post><table>
  93. <tr><td>Search For:<td><input type=text name=subject><tr><td>Price:<td><font color=grey><input type=text name=MinPrice size=6><input type=text name=MaxPrice size=6></font><td><input type=submit value=Search!>
  94. </table></form><hr><table width="100%">
  95.     <td align="left" width="20%">Date</td>
  96.     <td align="left" width="40%">Title</td>
  97.     <td align="Center" width="20%">Price</td>
  98.     <td align="Center" width="20%">Location</td>
  99.  
  100. <?php
  101. //database connection here
  102. $user = ('account');
  103. $pass = ('account');
  104. $host = ('localhost');
  105. $link = mysql_connect('localhost', 'account', 'account'); 
  106. if (!$link) { 
  107. mysql_select_db("user", $link);
  108.  
  109. function create_div($width, $fields, $table, $w_field, $w_value, $unique){
  110. $f = implode("`, `", $fields);
  111. $sql = "SELECT Description FROM post";
  112. $link = mysql_query($sql) or die(mysql_error());
  113. $div = "<div id=\"data".$unique."\" style=\"display:none; position:absolute; border-style:none; background-color:white; padding: 0px; width:".$width."px\" />\n";
  114.   while($r = mysql_fetch_assoc($link)){
  115.     foreach($fields as $name){
  116.     $div .= $r[$name]." ";
  117.     }
  118.   $div .= "<br />";
  119.   }
  120. $div .= "</div>\n";
  121. return $div;
  122. }
  123.  
  124. $sql = "SELECT * FROM post";
  125. $link = mysql_query($sql) or die(mysql_error());
  126. $i=0;
  127. $fields = array("Title", "Description");
  128. while($r = mysql_fetch_assoc($link)){
  129.   echo create_div("200", $fields, "models", "Title", $r['Title'], $i);
  130. ?>
  131.        <tr>
  132.        <td><?php echo $r['Date Created']; ?></td>
  133.        <td><a onmouseover="ShowContent('data<?php echo $i; ?>'); return true;" onmouseout="HideContent('data<?php echo $i; ?>'); return true;" href="javascript:ShowContent('data<?php echo $i; ?>')"><?php echo $r['Title'];?></a>
  134.  
  135.     <td>$<?php echo $r['Price']; ?></td>
  136.     <td><?php echo $r['Location']; ?></td></tr>
  137. <?php
  138. $i++;
  139. }
  140. ?>
Jan 3 '10 #1
5 4604
Dormilich
8,658 Expert Mod 8TB
well, your PHP function that fetches the description indeed outputs all descriptions for every title. why you wrote that function, I don’t understand, since the correct description is included in the original resultset.

PS. JavaScript is not at fault here, it only shows the results.

PPS. if (document.all) will also be triggered in Opera
Jan 3 '10 #2
What do i have to change? Sorry, I'm still new to this and found the js script online, the script itself is working but the popup should only display the contents of that row.
Jan 3 '10 #3
Dormilich
8,658 Expert Mod 8TB
change your PHP so that it only prints the correct description.
Jan 3 '10 #4
can you tell me where to look? I'm not asking for you to do it for me, but I have no idea where to start as its working but displaying every description record
Jan 4 '10 #5
Dormilich
8,658 Expert Mod 8TB
my personal opinion – discard create_div(). all you need should be fetched in line 126. a simple div (line 135, having a class to trigger the JavaScript) holding the description should do.
Jan 4 '10 #6

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

Similar topics

7
by: Samir | last post by:
I would like to get a little window (101x73) to appear on onmouseover and go away onmouseout. the onclick works. <html> <head> <meta http-equiv="Content-Language" content="en-us"> <meta...
7
by: windandwaves | last post by:
Hi Gurus I am trying to make this rather complicated maps with an a huge number of mouseovers and the like. I want to set up a function that OnMouseDown swaps the OnMouseOver and OnMouseOut for...
3
by: drjackk | last post by:
Hello, I'm trying to change the onmouseover event dynamically. This sets-up the initial onmouseover event: <a href="home.html"> <img border="0" id="img22" src="images/home1.jpg"...
2
by: MrCode2k | last post by:
Hello, Trying to do: I just want a table that I can scroll and that has fixed headers. Problem: I got it to work but when I added the onmouseover event it didn't work anymore....
7
by: MrCode2k | last post by:
Hello, Trying to do: I just want a table that I can scroll and that has fixed headers. Problem: I got it to work but when I added the onmouseover event it didn't work anymore....
1
by: den2005 | last post by:
Hi everybody, I am confused and still looking why this codes is not working. Can anyone notice or know why this code is not working? Thanks in advance. Code working: <form id="form1"...
1
by: Ciuin | last post by:
Again I need your help. This is the test page I am working on: http://www.manfredkooistra.de/zeugs/test/test.php Description: The page shows a centered image and a navigation menue...
3
by: equazcion | last post by:
Hi, I have an image reference (IMG) in my page that changes depending on the value of a database field. Clicking the image triggers an Ajax call to change the database field (toggles the field...
1
by: aasna | last post by:
hi I tried to use a onmouseover function in an ASP page, <a href="#" class="hintanchor" onMouseover="showhint('Please enter a valid username. Should consist of alphanumeric characters only.',...
2
by: ismailc | last post by:
Hi, I need help please! Onmouseover it calls a function, but onmouseover the image it changes the cursor from default ot busy the whole time. I want it to stay to default. I have set it o...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

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.