I need to choose between image and video from database with php (if – else) [closed]

I’m pulling pictures and videos from database. I want to create an if else with php and hide normal photo if there is video.

<?php
if (count($maschine->Bild)) {
  echo "<img src='<?php echo $lBild; ?>' class='latest-img' style='object-fit:scale-down; height: 100%' />";
} 
else
{
  echo "<video width='100%' controls autoplay muted loop src='<?php echo $lBild; ?>'></video>";            
}

?>