JazzyB Posted June 29, 2010 Share Posted June 29, 2010 Hi I am having a problem with data showing on a javascript tooltip. <?php $details = '<ul><li>list one </li><li>list two</li><li>list three </li><li>list four </li></ul>'; echo '<a href="javascript:void(0);" onMouseover="ddrivetip(\'.$details.\')" onMouseout="hideddrivetip()">More Details</a>'; ?> A tooltip appears when I put arrow over 'More Details' link however the tooltip shows '$details' instead of the actual list. Please help. Quote Link to comment https://forums.phpfreaks.com/topic/206215-php-data-in-js-tooltip/ Share on other sites More sharing options...
PFMaBiSmAd Posted June 29, 2010 Share Posted June 29, 2010 You are missing the single-quotes that actually break out of and back into the php quoted string - echo '<a href="javascript:void(0);" onMouseover="ddrivetip(\''.$details.'\')" onMouseout="hideddrivetip()">More Details</a>'; Quote Link to comment https://forums.phpfreaks.com/topic/206215-php-data-in-js-tooltip/#findComment-1078882 Share on other sites More sharing options...
JazzyB Posted June 29, 2010 Author Share Posted June 29, 2010 Thanks for the quick reply. Adding single quotes works except for when the variable $details is data pulled from database: $query = "SELECT * FROM table WHERE status = 1 ORDER BY name LIMIT 0, 10"; $result = mysql_query($query) or die (mysql_error()."<br />Couldn't execute query: $query"); //then get your results onto your page. $num_rows = mysql_num_rows($result); $info = mysql_fetch_array($result); $details = $info['details']; The data in db is stored as text and first data is: <ul><li>list one </li><li>list two</li><li>list three </li><li>list four </li></ul> Quote Link to comment https://forums.phpfreaks.com/topic/206215-php-data-in-js-tooltip/#findComment-1078897 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.