Dynamic Slider able to get all data from Database but is only able to display all data on the first slider. Instead of displaying subsequently in the sliders. Sorry for the stupid question, been working on this for weeks and couldn't seem to find any solution. The while loop within the php shouldn't be a problem but I might be wrong. Can anyone please enlighten me?
PHP
<?php
$connect = mysqli_connect("localhost", "root", "", "db");
$result = make_query($connect);
function fetch_array(&$array) {
// Grab the first value from the array
$return = current($array);
// remove the value we just grabbed
array_shift($array);
// if what we have is an array spit it out, else return false
return is_array($return) ? $return : false;
}
function make_query($connect) {
$query = "SELECT * FROM db.slider ORDER BY p_id ASC";
$result = mysqli_query($connect, $query);
return $result;
}
function make_slides($result) {
$output = '';
$count = 0;
while($row = mysqli_fetch_assoc($result)) {
// while($row = fetch_array($result)) {
// Not needed as the output is the same
//if($count == 0) {
$output .= '
<div class="swiper-slide platform">
<img src="'.$row["p_img"].'" alt="'.$row["p_name"].'" />
<div class="swiper-slide platform">
<h3>'.$row["p_desc"].'</h3>
</div>
</div>';
// Not used at the moment
$count++;
//echo json_encode($row);
echo $output;
}
return $output;
}
JS SWIPER
<script>
var swiper = new Swiper('.swiper-container.platform', {
effect: 'coverflow',
initialSlide: 0-5,
grabCursor: true,
centeredSlides: true,
slidesPerView: 'auto',
coverflowEffect: {
rotate: 0,
stretch: 0,
depth: 800,
modifier: 1,
slideShadows: true,
},
pagination: {
el: '.swiper-pagination',
}
});
</script>