Monday 28 March 2016

Use Marquee tag with PHP and Mysql - PHP Tutorial

In this post we are going to learn how to use Marquee tag with PHP and Mysql. Marquee tag is used to display scrolling text in up and down, right and left direction on web page. With the help of PHP programming language and Mysql database we can scrolling dynamic text in marquee tag. For stopping moving text we can write this code - onmouseover="this.stop();" and suppose friends If you want to again start moving text you can use this code - onmouseout="this.start();". You can also set the scrolling speed in attribute like scrollamout by entering number in this attribute. By using php and mysql we can easily fetch data from database table and display under marquee tag. Here we can display latest post or news by writing proper sql query. Implementation of this things is very easy and it is easy to understand.

Source Code


 $connect = mysqli_connect("localhost", "root", "", "test_db");  
 $sql = "SELECT * FROM tbl_video ORDER BY video_id LIMIT 5";  
 $result = mysqli_query($connect, $sql);  
           <meta name="viewport" content="initial-scale=1.0, user-scalable=no">  
           <meta charset="utf-8">  
           <title>Webslesson Tutorial</title>  
           <script src="jquery.js"></script>  
           <script src="js/bootstrap.js"></script>  
           <link href="css/bootstrap.css" rel="stylesheet" />  
           <div class="container" style="width:500px; border:1px solid #ccc;">  
                <br />  
                <marquee behavior="scroll" direction="up" onmouseover="this.stop();" onmouseout="this.start();">  
                     if(mysqli_num_rows($result) > 0)  
                          while($row = mysqli_fetch_array($result))  
                               echo '<label><a href="'.$row['video_link'].'" target="_blank">'.$row['video_title'].'</a></label>';  
                <br />                 


  1. Are you robot?....the way you talk bro ...but thank for your nice tutolia

  2. Lovely tutorial, but I really would like it to have the lately published last five titles (headings) of the news. I am getting all the old ones only.