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.