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
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>

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.