How to scroll div contents vertically in a loop like news feed in php page
<p>I'm making a Php webpage right now and would like to have a little "News" DIV on the right. that has auto scrolling vertical text as soon as the page loads. But, the below code not working in php page.</p>

<pre><code> &lt;html&gt;
 &lt;head&gt;
    &lt;script src="https://code.jquery.com/jquery-3.0.0.js" 
    integrity="sha256-jrPLZ+8vDxt2FnE1zvZXCkCcebI/C8Dt5xyaQBjxQIo=" 
    crossorigin="anonymous"&gt;
    &lt;/script&gt;

       &lt;style&gt;
        span 
        { 
          display:block;
          width:350px;
          word-wrap:break-word;
        }

        .display 
        {
          height:200px;
          border:none;
          overflow: hidden;
          padding:5;
        }
       &lt;/style&gt;

  &lt;/head&gt;

 &lt;body onLoad="scroll()" style="background-color: black;"&gt;

 &lt;!---***************** Php Code Start ************************---&gt;
 &lt;?php

   error_reporting(E_ALL ^ E_DEPRECATED);

 //********************* DB Configuration Code *********************
   ob_start();
   define('DB_SERVER', 'localhost');
   define('DB_USERNAME', 'xxxx');
   define('DB_PASSWORD', '');
   define('DB_DATABASE', 'MyDb');

    $connection = mysql_connect(DB_SERVER, DB_USERNAME, DB_PASSWORD) or die(mysql_error());
    $database = mysql_select_db(DB_DATABASE) or die(mysql_error());

    //************** Selection of Data *********************
    $select=mysql_query("SELECT * FROM newsfeedtest order by created asc");
    $i=1;

   //************* Display Data *********************
     while($userrow=mysql_fetch_array($select))
     {

        $id=$userrow['id'];
        $usernews=$userrow['news'];
        $created=$userrow['created'];

   //******** Div Displays Data *******
     echo  '&lt;div class="display" id="news" style="width:350px; margin-bottom:-20px;"&gt;

        &lt;!-------------------- News : ---------------------------------&gt;
          &lt;p style="color:#fff;"&gt;
          &lt;span style="color: #fff;font-size:17px;"&gt;'.$usernews.'&lt;/span&gt; &lt;/p&gt;&lt;br /&gt;

        &lt;/div&gt;';
      }

       //********************* End of Php Code *********************
     ?&gt; 


      &lt;script language="javascript"&gt;
        i = 0
        var speed = 1
        function scroll() 
        {
          i = i + speed
          var div = document.getElementById("news")
          div.scrollTop = i
          if (i &gt; div.scrollHeight - 160) {i = 0}
          t1=setTimeout("scroll()",100)
        }
      &lt;/script&gt;

     &lt;/body&gt;

    &lt;/html&gt;
</code></pre>

<p>Also, can it possible that on Mouseover to stop the scroll and on mouse out scrolling starts continue in a loop.
I've tried searching for the correct code, but nothing has worked thus far.   </p>

<p>" I'm just so frustrated now ! " </p>

<p>Any help would be immensely appreciated!</p>