Hello, I am new to web development and PHP/JS. I am currently using JWPlayer to show video on our church website using an xml playlist and all is working fine but it is rather cumbersome to upload new videos/Mp3 files. Each time we want to add a new video or audio we have to upload it to the server and change the xml playlist file. This works "OK" but i would like to change it so that it is more dynamic. What I would like to do is have PHP to read a folder and generate a list or table of the files and then the user would click on the one they want to listen to. I can already read the folder contents and put the contents in a table however when I put the onClick event tag in for the table i start getting errors. No particular error definition, it just says unexpected "" on line whatever and when I look at that line it is empty. When i take out the event tag everything displays ok but of course when I click in the file nothing happens.
Basically what I want to be able to do is:
upload a file to the server and have it update and play on the website without having to modify a playlist xml file. make it more dynamic.
Any suggestions on how i should implement this.
My PHP code is below..
<?php
$sermonDirectory = opendir("Sermons");
// gets each entry in the directory
while($entryName = readdir($sermonDirectory)) {
$dirArray[] = $entryName;
}
//close the directory
closedir($sermonDirectory);
//Sort the Array
sort($dirArray);
//count the elements
$count = count($dirArray);
//Start the list
printf ("<ul>\n");
for($index = 0; $index < $count; $index++)
{
$ext = pathinfo($dirArray[$index], PATHINFO_EXTENSION);
if($dirArray[$index] !='.' && $dirArray[$index]!='..' && $ext!="xml")
{
printf ("<li><a href='#' onclick='jwplayer().load('$dirArray[$index]')'>\n");
printf ("$dirArray[$index]");
printf ("</a></li>\n");
}
}
printf ("</ul>\n");
?>