Home » Php » How to bind all the images in carousel?

How to bind all the images in carousel?

Posted by: admin October 26, 2017 Leave a comment

Questions:

I am getting this error
Warning: mysqli_stmt::bind_param(): Number of variables doesn’t match number of parameters in prepared statement in C:\xampp\htdocs\Test\viewpro_img.php

I am not fetching the images but its showing in carousel form.
On the basis of property_id(integer) I want to fetch all the images in carousel form.

I am using bootstrap and jquery.
Any help will be appreciated…

Thanks in advance…

 <body id="top">
  <div class="container"> 
  <div id="myCarousel" class="carousel slide" data-ride="carousel" data-interval="500">
    <!-- Indicators -->
    <ol class="carousel-indicators">
      <li data-target="#myCarousel" data-slide-to="0" class="active"></li>
      <li data-target="#myCarousel" data-slide-to="1"></li>
      <li data-target="#myCarousel" data-slide-to="2"></li>
   <li data-target="#myCarousel" data-slide-to="3"></li>
    </ol>
<?php 
    $property_id=$_POST['property_id'];
 $sql="select property_img from img_tbl where property_id='$property_id'";


    if($stmt=$conn->prepare($sql)){

 $stmt -> bind_param('i',$property_id);
    $stmt -> execute();
    $stmt->bind_result($property_img);

      while($r1=$stmt->fetch())
   {
     $property_img1=$r1['property_img'];
   $property_img2=explode(' ',$property_img1);

       ?> 
    <!-- Wrapper for slides -->
    <div class="carousel-inner">
      <?php 
   foreach($property_img2 as $data)
   {
      echo '<div class="col-sm-6 item active form-group">
   <span><img class="img-zoom" src="uploads/'.$data.'" width="200" height="250" alt="not fetched"></span>
   </div>

   <div class="col-sm-6 item form-group">
   <span><img class="img-zoom" src="uploads/'.$data++.'" width="200" height="250" alt="not fetched"></span>
   </div>';   
          } ?>

    </div>

    <!-- Left and right controls -->
    <a class="left carousel-control" href="#myCarousel" data-slide="prev">
      <span class="glyphicon glyphicon-chevron-left"></span>
      <span class="sr-only">Previous</span>
    </a>
    <a class="right carousel-control" href="#myCarousel" data-slide="next">
      <span class="glyphicon glyphicon-chevron-right"></span>
      <span class="sr-only">Next</span>
    </a>
 <?php      
    }
    }
  ?>
  </div>
</div>


 </body>
Answers: