Retrieve the meaning of a word using ajax and javascript and php

Hi all,

I have an HTML document and a MySQL database.. In that document i have so many words including words in the database. Actually i have to highlight the words which are in the database. While mouse hovering those words their meaning should come as a tooltip.

Can anyone help with this…

Seeing as you didn’t mention it, are you even using PHP? Do you intend to code this yourself or are you looking for someone to do it for you?

This is my code:

<?php $con = mysql_connect('localhost', 'root', ''); if (!$con) { die('Could not connect: ' . mysql_error()); } $db=mysql_select_db("amr", $con); $comment="There are thousands ready to die for their religion, but only are few willing to live by its principles. Because of their narrow vision and envy, they have missed the true essence and message of religion which is love and compassion"; $c=explode(" ",$comment); for($i=0;$i<count($c);$i++) { echo $c[$i]." "; //echo "
"; $sql="SELECT * FROM dictionary WHERE word = '".$c[$i]."'"; $result = mysql_query($sql); while($row = mysql_fetch_array($result)) { /*echo $row[0]; echo ":"; echo $row[1]; echo "
";*/ if($c[$i]==$row[0]) { ?> class="tooltip" title="<?php echo $row[1];?>"><?php echo $c[$i];?> <?php } else { echo $c[$i]." "; } }

}

mysql_close($con);
?>

OUTPUT: There are thousands ready ready to die die for their religion, but only are few willing to live by its principles. Because of their narrow vision and envy, they have missed the true essence and message message of religion religion which is love and compassion compassion

The words repeating are coming from the database and their meanings appear as tooltips.Anyone help with this.

OK, so when you display the page in your browser, what happens? Does it do what you want? Do you see any errors? What isn’t working (if anything)? It’s good if you can be really descriptive in how the script isn’t doing what you want it to.

I’ve just noticed you posted this topic in two forums:
http://www.phphelp.com/forum/index.php/topic,12718.0.html

That’s not good as you now have two different people replying in different topics…

Sponsor our Newsletter | Privacy Policy | Terms of Service