How do I make a PHP file work inside an HTML with Bluehost
one text
So I am trying to make a PHP file look through my database, find all of my images, and print them, I have watched a few people do this to make sure I got the code right since I am a little new to PHP. the code is
<?php
$dir_path = 'Albums/portaits';
$ext_array = array('jpg', 'png', 'jpeg');
if(is_dir($dir_path))
{
$files = scandir($dir_path);
for($i = 0; $i < count($files); $i++)
{
if($files[$i] !='.' && $files[$i] !='..')
{
//get file name
echo "File Name -> $files[$i]<br>";
//get file ext
$file = pathinfo($files[$i]);
$extension = $file['extension'];
echo "File Extension-> $extension<br>";
echo "img src='$dir_path$files[$i]'>";
}
}
} ?>`
I have no idea how to input or call this in HTML and I am unable to do the same as the people in the video.
I am sure that the images are on the server doing mysite.come/images. I see the directories and all on the site. My plan is to make a portfolio page, where I have a little drop-down (that's all css and I think I understand that much lol) and it displays the images of what the PHP calls. the idea is that I won't need to add 50 lines of <img>
and I can add images by just uploading an updated folder