Marsha Posted September 15, 2009 Share Posted September 15, 2009 Hey The problem is, I have a JS script for Hover over buttons, which adds information in a little table when you hover over some text, I have a php script which sets out 4 different title names from MySQL. I have entered the JS into the PHP correctly and It works but Only for One of the title names, I want each title to show each description also from MySQL So, you go onto the page, and there are 4 different titles, collected from MySQL, I hover over the first title and it comes up with the description perfectly, but all the other titles come up with the description of the first one. Code is below JS CODE <script type="text/javascript"> function ShowPopup(hoveritem) { hp = document.getElementById("hoverpopup"); // Set popup to visible hp.style.visibility = "Visible"; } function HidePopup() { hp = document.getElementById("hoverpopup"); hp.style.visibility = "Hidden"; } </script> Body Code echo '<td align="center"><a id="hoverover" style="cursor:default;" onMouseOver="ShowPopup(this);" onMouseOut="HidePopup();">',$row['title'],'</a><br />'; echo '<body><div id="hoverpopup" style="visibility:hidden; position:absolute; z-index:1; top:300; left:20; height: 71px; width: 99px">' . $row['description'] . '</div></body>'; $row['title'] = Title $row['description'] = Description Quote Link to comment https://forums.phpfreaks.com/topic/174302-this-is-js-but-mainly-a-php-problem-please-help/ Share on other sites More sharing options...
Marsha Posted September 15, 2009 Author Share Posted September 15, 2009 nobody know? Quote Link to comment https://forums.phpfreaks.com/topic/174302-this-is-js-but-mainly-a-php-problem-please-help/#findComment-918853 Share on other sites More sharing options...
RichardRotterdam Posted September 15, 2009 Share Posted September 15, 2009 If your fetching multiple records from a db you could create an unique id for div element something like: <?php for($i=0; $i<sizeof($records); $i++ ): ?> <a onMouseOver="ShowPopup('hoverpopup<?php echo $i; ?>');" onMouseOut="HidePopup('hoverpopup<?php echo $i; ?>');">link</a> <div id="hoverpopup<?php echo $i; ?>"> <!-- popup stuff --> </div> <?php endfor; ?> Quote Link to comment https://forums.phpfreaks.com/topic/174302-this-is-js-but-mainly-a-php-problem-please-help/#findComment-918864 Share on other sites More sharing options...
Marsha Posted September 15, 2009 Author Share Posted September 15, 2009 Hmmm, Well the Script I am editing is Downloads.php in the Downloads system mod for SMF, A Fairly large script so I don't know where anything is lol Quote Link to comment https://forums.phpfreaks.com/topic/174302-this-is-js-but-mainly-a-php-problem-please-help/#findComment-918867 Share on other sites More sharing options...
Marsha Posted September 15, 2009 Author Share Posted September 15, 2009 Actually that is a very good idea! Does the $i Represent the $row['title']? Quote Link to comment https://forums.phpfreaks.com/topic/174302-this-is-js-but-mainly-a-php-problem-please-help/#findComment-918896 Share on other sites More sharing options...
Marsha Posted September 16, 2009 Author Share Posted September 16, 2009 Quote Link to comment https://forums.phpfreaks.com/topic/174302-this-is-js-but-mainly-a-php-problem-please-help/#findComment-919346 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.