PHP Javascript Show/Hide button not working
<p>This is my php code:</p>

<pre><code>&lt;?php
require('connection.php');
$query="select title,content from blogs";
echo '&lt;html&gt;&lt;head&gt;';
echo '&lt;link rel="stylesheet" href="blog.css" /&gt;';
echo '&lt;script type="text/javascript" src="blog.js"&gt;&lt;/script&gt;&lt;/head&gt;&lt;body&gt;';
$i=0;
if($result=$mysqli-&gt;query($query))
{
while($news=$result-&gt;fetch_row())
{
echo "&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;". $news[0]."&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;";
if(strlen($news[1])&gt;60)
{
    $d=0;
    $content=explode(" ",$news[1]);
    foreach($content as $c)
    {
        if($d&lt;=60)
        {
            echo $c." ";
            $d++;
        }
        else
        {
            if($d==61)
            {

                echo "&lt;div id=a$i style='visibility:hidden'&gt;";
                echo "&lt;a href='#' onclick='toggle(a".$i.")' style='visibility:visible'&gt;Show/Hide&lt;/a&gt;";

                $i++;

                $d++;
            }
            echo $c." ";
            $d++;
            if($d==count($content)+1)
            {
                echo "&lt;/div&gt;";
            }

        }


    }
}
else
echo $news[1]."&lt;br /&gt;&lt;br /&gt;";

}
$result-&gt;close();
echo "&lt;/body&gt;&lt;/html&gt;";

}
?&gt;
</code></pre>

<p>This is my JavaScript code:</p>

<pre><code>function toggle(id)
{

    //document.getElementById('mcontent').value=x++;
    //if(x%2==0)
    document.getElementById(id).style.visibility="visible";
    //else
    //document.getElementById('mcontent').style.visibility="hidden";
};
</code></pre>

<p>The show hide button is not working.My strategy is to limit text which contains more than 60 words with the show hide button.Once the user clicks the button the hidden div becomes visible and that contains the extra text(namely the text after 60 word count).Div element should always start with a letter so I have append letter 'a' before that.Please help me fix this.</p>

<p>Note:
<strong>Don't need Jquery solutions or suggestion.I need only to debug the above code.</strong></p>
