I am trying to write a script that displays images and/or mp4 files. The image and mp4 file names are stroed in a data table. When the script runs it needs to loop through the array returned by the mySQL statement. Each returned record has a column called "FileType" which contains either a 1 for an image file or 2 for an mp4 file.
My thinking is that as the do while loop is executed it looks at the content of "FileType" it is trapped by the if statement and uses the appropriate code to display the file. The issue I have is the script is only displaing rows where the column "FileType" contains 1.
So if the first row contains an image file, it displays, but if the row contains an mp4 file it is not displayed.
Can anyone see where I have gone wrong and how I can fix it so it loops through the array of rows and displays each one.
My code:
do {
$FileType = $row_signage['FileType'];
if($row['DisplayType'] == "P" ) {
$DisplayWdith = "1080";
$DisplayHeight = "1920";
} else {
$DisplayWdith = "1920";
$DisplayHeight = "1080";
}
?>
<div>
<?php if($FileType == 1) { ?>
<img src="/<?=$ImagePath . $row_signage['SignageImageName']?>" class="responsive"/>
<?php } elseif($FileType == 2) { ?>
<div id="video_player">
<video width="<?php echo $DisplayWdith;?>" height="<?php echo $DisplayHeight;?>" autoplay muted playsinline>
<source src="/<?php echo $ImagePath.''.$row['SignageImageName'];?>"/>
</video>
<?php } ?>
</div>
} while ($row_signage = mysqli_fetch_array($fb)); ?>