I wanna show tooltip with query data in php.
My php code is,
echo "<div class='tooltip' id='".$row['id']."' title='title1'>".$row['name']."</div>";
My Script is,
$(function() {
$('.tooltip').tooltip({
content:function()
{
var id =$(this)[0].id;
<?php
$qry3 = "SELECT phone_no FROM history WHERE id='?>id<?php' GROUP BY name";
$exc3 = mysql_query ($qry3,$con);
$num3 = mysql_num_rows($exc3);
while($rows3 = mysql_fetch_array($exc3))
{
array_push($name,'"'.$rows3[0].'"');
}
echo "return ".$name;
?>
}});
});
Where is my problem?
I think you are mixing up Javascript and PHP here. Your current PHP code get's executed only once when the server sends the Javascript to your browser. This cannot work. You can either store the tooltip for each HTML element e.g. in the title tag or you should load it dynamically whenever the tooltip should be shown. You would do this via an AJAX call to a PHP file (and not by putting the PHP code in the JS file).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With