Here we have make
dynamic video carousel slider with Codeigniter code and Mysql. You can create
dynamic carousel video slider with code and mysql databse in codeigniter
framework. We have use codeigniter framework with mysql database in Bootstrap
carousel.
What is CodeIgniter?
CodeIgniter is based on the popular model–view–controller (MVC) development pattern. Controller classes are a necessary and main part of the CodeIgniter, models and views are optional. CodeIgniter is the faster framework of another PHP framework. In CodeIgniter we can easily INSERT, MODIFY and View data.
If you want to make video slider dynamically easily then use codeigniter simple script.
In this script all data fetch from Mysql table and create dynamic carousel slider.
So, If we want to display other video in the slider then just change table data and this codeigniter script will create slider as per data of your table and that will display at video in slider.
Now create database table as add_video in my Test database as below.
CREATE TABLE IF NOT EXISTS `add_video` ( `id` int(11) NOT NULL AUTO_INCREMENT, `title` varchar(200) NOT NULL, `url` varchar(200) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM AUTO_INCREMENT=10 DEFAULT CHARSET=latin1; |
Create Controller
<?php class Index extends CI_Controller { public function __construct() { parent::__construct(); } public function index() { $this->load->model('Slider'); $data['data'] = $this->Slider->fetch_data(); $this->load->view('slider', $data); } } ?> |
Now in the above controller we added model function fetch_data() To fetch the details of slider from database and store in an array $data[‘data’] and passed into view.
Create Model
<?php
class Slider extends CI_Model {
function __construct() { parent::__construct(); }
public function fetch_data() { $query = $this->db->query("SELECT * FROM add_video where 1 ORDER BY `id` DESC limit 40"); return $query->result_array(); } } ?> |
In Views :
we are fetch the details from table which is stored in array $data.
You can get Code from Here...
http://lpktechnosoft.com/software_file/slider.zip