1

I am experiencing a project roadblock I am unable to resolve and I am seeking advice/guidance.

I am controlling HTML content with PHP.

My goal is to create some sort of list that the user may select an option, that has dynamically pulled the file names of the items in the folder, and display that video in an embeded iframe.

I have attempted to save the selection into the $_SESSION or $_POST variable to compare with the items in the folder, until discovering a match, to set an iframe with the selected video. I have also attempted this with/without the html element of form.

Here is my code:

<div class="container-fluid col-lg-4 col-md-4 col-sm-12 leftside" style="margin-top: 25px;">
<h1>Chose a video</h1>
<form method="post">
    <select name="videoSelection" class="video selectpicker" data-style="btn-primary" data-width="fit" value="<?php echo $_POST['videoSelection'] ?>" >
        <?php
            if ($handle = opendir('../media/video/')) 
            {
                while (false !== ($file = readdir($handle))) 
                {
                    if ($file != "." && $file != "..") 
                    {
                        echo "<option value='$file'>$file</option>";
                    }
                }
                closedir($handle);
            }
        ?>
    </select>
</form>
</div>
<!-- RIGHT SIDE-- MAIN BODY-->
<div class="container" style="margin-top: 25px;">
<div class="row container-fluid">
    <div class="col-sm-8">
        <div class="embed-responsive embed-responsive">
            <?php
                if(isset($_POST['videoSelection']))
                { 
                    $videoSelection = $_POST['videoSelection']; 
                }
                else
                {
                    echo "<h2>Variable Not set!</h2>";
                }

                if ($handle = opendir('../media/video/')) 
                {
                    while (false !== ($newFile = readdir($handle))) 
                    {

                        if ($newFile == $videoSelection) 
                        {                            
                            echo '<iframe class="embed-responsive-item" src="$file" allowfullscreen></iframe>';
                        }
                        else
                        {
                            echo var_dump($videoSelection);
                        }
                    }
                    closedir($handle);
                }
            ?>
        </div>
    </div>
</div>
</div>
Chris
  • 11
  • 3

0 Answers0