Jump to content

PHP Data in JS tooltip


JazzyB

Recommended Posts

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.

Link to comment
https://forums.phpfreaks.com/topic/206215-php-data-in-js-tooltip/
Share on other sites

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>

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.