Posted inphp / JavaScript / jQuery / Mysql / Mysqli

how to create dynamic image slider in php?

Today, We want to share with you image slider in php.In this post we will show you image slideshow from database php jquery, hear for PHP image slideshow auto we will give you demo and example for implement.In this post, we will learn about Create Dynamic Image Slider using PHP with jQuery with an example.

How to Create Dynamic Image Slider Using PHP and Bootstrap?

How to upload images using PHP and HTML Form?

HTML Form

" enctype="multipart/form-data">

Server Side code in PHP

if(isset($_POST["submit"])){
    $getImage=  basename($_FILES["Image"]["name"]);
    if($getImage==""){
        echo "Please choose";
    }
    else
    {
        $target="../sliderImage/";
        $ran=time();
        $target=$target.$ran.$getImage;
        $imageName=$ran.$getImage;
        
        if($_FILES["Image"]["type"]=="image/jpg"||$_FILES["Image"]["type"]=="image/jpeg"){
            move_uploaded_file($_FILES["Image"]["tmp_name"], $target);
            if(move_uploaded_file){
                include_once './slider/slideshowController.php';
                $slideshowController=new SlideshowController();
                $slideshowController->uploadSlider($imageName,$_POST["Big"],$_POST["Small"]);
            }
            else
            {
                echo "File is not uploaded";
            }
        }
        else
        {
            echo "Please choose Image";
        }
    }
}

slideshowController.php

public function uploadSlider($image,$big,$small){
        $insert="Insert into slider (profilepicture,BigText,SmallText) values ('$image','$big','$small')";
        $result=$this->query($insert);
        if($result){
            echo "File is uploaded";
        }
        else
        {
            echo "File is not uploaded";
        }
    }

show the images slider using PHP and Bootstrap
index.php

listSlider();
?>




  
    
    Previous
  
  
    
    Next
  

used listSlider function in php

public function listSlider(){
        $select="select * from slider";
        $result=$this->query($select);
        $count=$result->num_rows;
        if($count< 1){
            
        }
        else
        {
            while ($row = $result->fetch_array()) {
                $rows[]=$row;
            }
            return $rows;
        }
    }

Database Table

CREATE TABLE IF NOT EXISTS `slider` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `profilepicture` varchar(250) NOT NULL,
  `BigText` varchar(250) NOT NULL,
  `SmallText` varchar(500) NOT NULL,
  PRIMARY KEY (`ID`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=4 ;

I hope you get an idea about how to make dynamic carousel in php?.
I would like to have feedback on my infinityknow.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.

I am Jaydeep Gondaliya , a software engineer, the founder and the person running Pakainfo. I'm a full-stack developer, entrepreneur and owner of Pakainfo.com. I live in India and I love to write tutorials and tips that can help to other artisan, a Passionate Blogger, who love to share the informative content on PHP, JavaScript, jQuery, Laravel, CodeIgniter, VueJS, AngularJS and Bootstrap from the early stage.

Leave a Reply

Your email address will not be published. Required fields are marked *

We accept paid guest Posting on our Site : Guest Post Chat with Us On Skype