Before we see how that demo works let’s check how we create this demo.
First of all, Create the Database Table and take fields you require if you don’t have a table yet.Use the following syntax to create the table.
CREATE TABLE news_ticker ( `id` INT( 11 ) NOT NULL AUTO_INCREMENT PRIMARY KEY `text_short` VARCHAR( 255 ) NOT NULL , `image` VARCHAR( 255 ) NOT NULL ) ENGINE = MYISAM;
After creating a table, create one page ticker.php and add the following script in Head tag as we are using script it is better to add code in Head Tag or you can add anywhere in Page as per your requirement.
Above Code will do MySQL connection and fetch the data from the database and loop the data and using that data display as ticker.Here I am adding all html content to the global variable as an array and for ticker display, using array value one by one. After adding above code in the head tag, Add below line in Body.
That’s it and your ticker is ready and checks your ticker on the frontend.
Have a look at the working demo here Ticker for DB values.