automating current static page with 3 directory contents on the fly

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • malcsman
    New Member
    • Apr 2009
    • 6

    automating current static page with 3 directory contents on the fly

    Hi there,

    I think it's best to explain things first.. (it's a sermons archive)
    I manage a static page which I'd like to automate. This page is an archive that lists mp3s and their notes(pdf) as well as zip files. Every week i have to add two new mp3s and their pdf notes, remove entries and add a zip.
    if you'd like to see what it looks like, to maybe understand me: http://www.eastside.org.za/index.php?pageid=1552

    each file type is in a separate directory, ie: Sermon/mp3, Sermon/pdf, Sermon/zip. I dont have a database to make use of and because of this I'm not sure where to start. I did try with an array, but I got lost when things didnt work.

    I would really appreciate someone pointing me in the right direction. It seemed rather easy when I started with just a directory listing, but when I put the list in an array and tried to extract the name of the sermon giver using split() and my brain going ahead of me thinking of ordering everything according to the date, I decided to ask for help.

    I started with one directory to make things simpler for myself.
    I dont code clean when I'm trying to figure things out. each time i try something new, I comment out what was tried. I know it is a mess, but as i said, i'm lost as to what i should do.

    Here Is My Code (see results of code below):

    Code:
    <?php //http://www.eastside.org.za/index.php?page=newsermons
    /* PROJECT Begun On 18 April 2009
    DATE started: Sat 18 Apr 2009;
    TIME started: 10:00AM;
    DATE stopped: Sun 19 Apr 2009
    TIME stopped: 01:51AM;
    */
    //this is very much USELESS when i break it, as the php code is within a CMS - if something is wrong, I get a blank page :o(
    error_reporting(E_ALL);
    $dirname = "UserFiles/eastside.intoweb.co.za/Sermons/mp3";
    $dir = opendir( $dirname );
    		$mp3list2 = array();
    		$noddy = array();
    		$noddy2 = array();
    		$ff = 0;
    		$file_list = "";
    
    while( false != ( $file = readdir( $dir ) ) ) {
    	if( ( $file!= "." ) and ( $file != ".." ) ) {
    		$file_list .= "<li>$file</li>";
    		//$mp3list = explode( " ", $file );
    		$mp3list = split( '[ .]', $file );
    		//THIS LINE v
    		array_push( $mp3list2, split( '[ .]', $file ) );
    		//array_push( $mp3list2, 'day' => array($mp3list[0]), 'month' => array($mp3list[1]), 'year' => array($mp3list[2]), 'time' => array($mp3list[3]), 'preach' => array($mp3list[4]), 'ext' => array($mp3list[5]) );
    		//THIS LINE v
    		//$mp3day = $mp3list[0]; $mp3month = $mp3list[1]; $mp3year = $mp3list[2]; $mp3time = $mp3list[3]; $mp3preach = $mp3list[4]; $mp3ext = $mp3list[5];
    		//AND THIS LINE TOO v 
    		//array_push( $mp3list2, 'day' => $mp3day, 'month' => $mp3month, 'year' => $mp3year, 'time' => $mp3time, 'preach' => $mp3preach, 'ext' => $mp3ext );
    /*
    		-catch all preachers with  element 4 into preacher array['nameofpreacher',$sermons];
    		-$sermons in each pastor = the sermons that that preacher gave;
    		-for every preacher in array, there will be their heading: Bruce, Riaan, Guest;
    		-under each heading a list of sermons given plus a link to their mp3
    		-- keeping in mind the sermon-notes associated with that sermon:
    		sermon1 - note1
    		sermon6 - note6
    		sermon4 - note4
    */
    		//I'm lost, so i'm just screwing around..
    		$noddy = array( list( $sday, $smonth, $syear, $stime, $spreach ) = split( '[ .]', $file ) );
    		list( $sday, $smonth, $syear, $stime, $spreach ) = split( '[ .]', $file );
    		if( $spreach == "Bruce" ) {
    			////FREAK, i was so close, but array_push just doesnt work...
    			$noddy2 = array( "bruce" => array($sday, $smonth, $syear, $stime) );
    			//YES honey, array push doesnt work like above by just appending _push... ROTFLMAO
    			//so it broke
    			///array_push( $noddy2, "bruce" => array($sday, $smonth, $syear, $stime ) );
    			//will this do it?
    			///array_push( $noddy2, "bruce" => array( $ff => array($sday, $smonth, $syear, $stime ) ) );
    		} //and it didnt work BECAUSE of this - figures, it's AFTER 1AM!! 
    		$ff++;
    	}
    }
    
    closedir( $dir );
    
    //echo( "<title>$dirname</title>" );
    //echo( "<table><tr><td>$file_list</td><td>" );
    print_r( $mp3list );
    echo( "<br><br>" );
    print_r( $mp3list2 );
    //echo( "</td></tr></table>" );
    echo( "<br><h2>$mp3list[4]</h2>
    <a href='$dirname/$mp3list[0]%20$mp3list[1]%20$mp3list[2]%20$mp3list[3]%20$mp3list[4].$mp3list[5]'>
    $mp3list[0] $mp3list[1] $mp3list[2] $mp3list[3]</a>" );
    
    		echo( "<br><hr> $sday, $smonth, $syear, $stime, $spreach<hr><br>" );
    		print_r( $noddy );
    		echo( "<hr><hr><br>" );
    		print_r( $noddy2 );
    		echo( "<hr><hr><br>" );
    echo( '<br><br>'.implode(" ", $mp3list2[5]) ); 
    
    /*
    $pieces = explode(" ", $pizza);
    echo $pieces[0]; // piece1
    echo $pieces[1]; // piece2
    
    Example 2
    $data = "foo:*:1023:1000::/home/foo:/bin/sh";
    list($user, $pass, $uid, $gid, $gecos, $home, $shell) = explode(":", $data);
    echo $user; // foo
    echo $pass; // *
    // Delimiters may be slash, dot, or hyphen
    $date = "04/30/1973";
    list($month, $day, $year) = split('[/.-]', $date);
    echo "Month: $month; Day: $day; Year: $year<br />\n";
    */
    ?>
    i'll keep playing(screwin g) around, so if u wanna see if i have anything to show, have a look at the newsermons page. am i perhaps taking it from the wrong angle?

    Thanks so much
    SMiLE
  • Atli
    Recognized Expert Expert
    • Nov 2006
    • 5062

    #2
    Hi.

    The biggest problem with your layout is the file names. They are inconsistent.
    You need to settle on a fixed format, so that you can easily parse them into useful pieces in your code.

    Once you have done that, you can use the glob function to search for all the Mp3 files, and the file_exists function to make sure there is a PDF file that goes with it.

    For example, if I assume a file structure like this:
    Code:
    sermons/
        mp3/
            John Doe_2009-04-19.mp3
            John Doe_2009-03-12.mp3
            John Johnsson_2008-02-30.mp3
        pdf/
            John Doe_2009-04-19.pdf
            John Doe_2009-03-12.pdf
            John Johnsson_2008-02-30.pdf
    You could use the glob() function to search for all the Mp3 files, like so:
    [code=php]$mp3list = glob("sermons/mp3/*.mp3");[/code]
    Then you would need to parse the file names into names and dates, check if the Mp3 has a matching PDF file, and save all that into an array so you can print it later.
    [code=php]$names = array();
    foreach($mp3lis t as $_mp3file) {
    // Split the path into individual parts.
    $parts = explode('/', $_mp3file);

    // This uses regular expressions to
    // split the file name on all dashes (-) and dots (.).
    list($name, $date, $ext) = preg_split('/[_\.]/is', end($parts));

    // See if a PDF file exists
    $pdfPath = "serms/pdf/{$name}_{$date} .pdf";
    $pdfExists = file_exists($pd fPath);

    // Store the file in the $names array.
    $names[$name][$date] = array(
    'pdf' => $pdfExists
    );
    }[/code]
    Now you got all the files in a nicely formatted array, so you can sort it and print it in whatever way you want.
    For example:
    [code=php]// Go through the storage array and print every name
    foreach($names as $_name => $_dates) {
    // Sort the dates
    ksort($_dates);

    // Print the name
    echo "<div><strong>{ $_name}</strong><ul>";

    // Print each date, along with a link to the
    // Mp3 and the PDF (if any)
    foreach($_dates as $_date => $_values) {
    echo "<li>{$_dat e}: ",
    "<a href=\"serms/mp3/{$_name}_{$_dat e}.mp3\">Mp3</a>";
    if($_values['pdf']) {
    echo ", <a href=\"serms/pdf/{$_name}_{$_dat e}.pdf\">PDF</a>";
    }
    }

    // Print fotter
    echo "</ul></div>";
    }[/code]

    Which should print something like:
    Code:
    John Doe
        * 2009-03-12: Mp3, PDF
        * 2009-04-19: Mp3, PDF
    
    John Johnsson
        * 2008-02-30: Mp3, PDF
    See what I mean?

    Comment

    • malcsman
      New Member
      • Apr 2009
      • 6

      #3
      Originally posted by Atli
      Hi.

      The biggest problem with your layout is the file names. They are inconsistent.
      You need to settle on a fixed format, so that you can easily parse them into useful pieces in your code.
      I know there is a BIG difference between the mp3 name and the pdf name.
      Lucky for me, I'm the media and web guru for the church, so i can get a change..
      The file structure for the mp3 is (in php date format), "d M Y A" followed by the speaker_surname .mp3, so "19 Apr 2009 AM Bruce.mp3"
      for the moment the pdf has no logical structure : "name of sermon.pdf" - i'd like to follow the same structure as above, "19 Apr 2009 AM Bruce.pdf"
      Originally posted by Atli
      Once you have done that, you can use the glob function to search for all the Mp3 files, and the file_exists function to make sure there is a PDF file that goes with it.
      note that sometimes they never provide notes
      Originally posted by Atli
      For example, if I assume a file structure like this:
      Code:
      sermons/
          mp3/
              John Doe_2009-04-19.mp3
              John Doe_2009-03-12.mp3
              John Johnsson_2008-02-30.mp3
          pdf/
              John Doe_2009-04-19.pdf
              John Doe_2009-03-12.pdf
              John Johnsson_2008-02-30.pdf
      You could use the glob() function to search for all the Mp3 files, like so:
      [code=php]$mp3list = glob("sermons/mp3/*.mp3");[/code]
      Then you would need to parse the file names into names and dates, check if the Mp3 has a matching PDF file, and save all that into an array so you can print it later.
      [code=php]$names = array();
      foreach($mp3lis t as $_mp3file) {
      // Split the path into individual parts.
      $parts = explode('/', $_mp3file);

      // This uses regular expressions to
      // split the file name on all dashes (-) and dots (.).
      list($name, $date, $ext) = preg_split('/[_\.]/is', end($parts));

      // See if a PDF file exists
      $pdfPath = "serms/pdf/{$name}_{$date} .pdf";
      $pdfExists = file_exists($pd fPath);

      // Store the file in the $names array.
      $names[$name][$date] = array(
      'pdf' => $pdfExists
      );
      }[/code]
      should the filename rather be "19-Apr-2009_AM Bruce.mp3" so i can use regex, which i am SLOWLY learning in my job.
      Originally posted by Atli
      Now you got all the files in a nicely formatted array, so you can sort it and print it in whatever way you want.
      For example:
      [code=php]// Go through the storage array and print every name
      foreach($names as $_name => $_dates) {
      // Sort the dates
      ksort($_dates);

      // Print the name
      echo "<div><strong>{ $_name}</strong><ul>";

      // Print each date, along with a link to the
      // Mp3 and the PDF (if any)
      foreach($_dates as $_date => $_values) {
      echo "<li>{$_dat e}: ",
      "<a href=\"serms/mp3/{$_name}_{$_dat e}.mp3\">Mp3</a>";
      if($_values['pdf']) {
      echo ", <a href=\"serms/pdf/{$_name}_{$_dat e}.pdf\">PDF</a>";
      }
      }

      // Print fotter
      echo "</ul></div>";
      }[/code]

      Which should print something like:
      Code:
      John Doe
          * 2009-03-12: Mp3, PDF
          * 2009-04-19: Mp3, PDF
      
      John Johnsson
          * 2008-02-30: Mp3, PDF
      See what I mean?
      I do, thanks. I also take it that if my name for the files are "d-M-Y_A speaker surname.mp3", I can parse the date into "d M Y morning" and it would look like:
      Code:
      Bruce
      19 Apr 2009 morning (approx filesize)
      
      Madame Surname
      22 March 2009 evening (approx filesize)
      
      Name Surname
      22 March 2009 morning (approx filesize)
      
      Riaan von Silly-surname
      12 Apr 2009 morning (approx filesize) Notes
      12 Apr 2009 evening (approx filesize) Notes
      19 Apr 2009 evening (approx filesize) Notes
      noting that not everyone knows how to use capitals..when saving files...?!?
      i know I'm a monkey when it comes to sorting, but I'll worry about that later.

      thanks
      ps. I'll try this new structure and all by touching files in a new directory ;o)

      Comment

      • malcsman
        New Member
        • Apr 2009
        • 6

        #4
        I did it!!

        Thanks Alti (and Charl H from Intoweb), although I have a date sort problem in the dates of the zip files - dunno why :-( (I'd appreciate a hint ;-) )
        Without your help I prolly would have taken the long, wrong route...

        I know the code is messy, but I intend cleaning it up when the church is happy with the end result

        [code=php]<?php
        $dirname = "UserFiles/eastside.intowe b.co.za/Sermons/mp3/";
        $dirname2 = "UserFiles/eastside.intowe b.co.za/Sermons/pdf/";
        $dirname3 = "UserFiles/eastside.intowe b.co.za/Sermons/doc/";
        $dirname4 = "UserFiles/eastside.intowe b.co.za/Sermons/zip/";
        $sizeDivider = 1024; // Divide fileSize by
        $sermonFiles = "";
        $sermonZips = "";

        //$mp3list = glob("sermons/mp3/*.mp3");
        $mp3list = glob("$dirname* .mp3");
        /*$adate = array(
        'jan' => '01',
        'feb' => '02',
        'mar' => '03',
        'apr' => '04',
        'may' => '05',
        'jun' => '06',
        'jul' => '07',
        'aug' => '08',
        'sep' => '09',
        'oct' => '10',
        'nov' => '11',
        'dec' => '12'
        );*/
        $names = array();
        foreach($mp3lis t as $_mp3file) {
        // Split the path into individual parts.
        $parts = explode('/', $_mp3file);
        /* $fpart = preg_split('/[_\.]/is', end($parts));
        while (list($key, $val) = each($fpart)) {

        $udate = strtotime(subst r($val, 0, 14));
        print($udate);
        //print_r("<BR>". $key." == ".$val."<br >");
        }
        */
        // This uses regular expressions to
        // split the file name on all dashes (-) and dots (.).
        list($date, $name, $ext) = preg_split('/[_\.]/is', end($parts));

        // See if a PDF file exists
        $pdfPath = "$dirname2{$dat e}_{$name}.pdf" ;
        $pdfExists = file_exists($pd fPath);

        // See if a DOC file exists
        $docPath = "$dirname3{$dat e}_{$name}.doc" ;
        $docExists = file_exists($do cPath);

        // Turn $date into timestamp
        $predate = substr($date, 0, 11);
        $predate .= " ".substr($d ate, 12, 14);
        //echo($predate);
        $udate = strtotime($pred ate);
        //echo("bob".$uda te."pop<hr>");

        // Store the file in the $names array.
        // Lets put timestamp in front of names?
        $names[$udate][$name][$date] = array(
        'pdf' => $pdfExists,
        'doc' => $docExists
        ); //^^^^^//, 'timestamp' => $udate
        }
        //print_r($names) ;
        /* thanks Charl
        foreach($names as $name)
        {
        ## ok so here we make the dates into timestamps
        ## now you can put them into a array with the timestamp as the key and the values
        ## will be the data then just use ksort

        while (list($key, $val) = each($name)) {

        $udate = strtotime(subst r($key, 0, 11));
        echo($udate);
        print_r("<BR>". $key." ".$val."<br >");
        }
        print "-------<BR><BR>";
        }
        die();
        */ //PUT KSORT UP HERE noob
        // Sort the dates
        // sort da array by key
        ksort($names);
        // Go through the storage array and print every name
        foreach($names as $_udate => $_name) {
        /* doesnt work
        foreach($_dates as $_date => $_values) {
        ksort($_values['timestamp']);
        }
        */
        // Sort the names
        // sort da array by value
        //asort($names);
        /*
        echo("<br>_name : ");
        print_r($_name) ;
        echo("<BR");
        */
        // Print the name
        //echo "<div>1st foreach<strong> {$_name[0]}</strong><ul>";
        foreach($_name as $_names => $_dates) {

        // Print the name
        //echo "<div>2nd foreach<strong> {$_names}</strong><ul>";
        //echo "<div><strong>{ $_names}</strong><ul>";
        $sermonFiles .= "<span style=\"font-weight: bold; color: rgb(0, 0, 0); text-decoration: underline;\">{$ _names}</span><br /><br />";

        // Print each date, along with a link to the
        // Mp3 and the PDF (if any)
        foreach($_dates as $_date => $_values) {

        // Print the name
        //echo "<div>3rd foreach<strong> {$_names}</strong><ul>";
        $dated = $_date;
        /*
        echo "<hr>";
        print_r($_value s);
        */
        // Somewhere prolly here, need to parse the date, extracting 04 and turning it into Apr
        $dated = str_replace("-", " ",$dated);
        $mp3Size = filesize("$dirn ame{$_date}_{$_ names}.mp3");
        //echo($mp3Size." ");
        $mp3Size /= $sizeDivider; $mp3B = "KB";
        if($mp3Size > 1024) { $mp3Size /= $sizeDivider; $mp3B = "MB"; }
        //echo($mp3Size." ");
        $mp3Size = round($mp3Size, 2);
        //echo "<li>{$_dat e}: ",
        //echo "<li>",
        // "<a href=\"$dirname {$_date}_{$_nam es}.mp3\">{$dat ed}.mp3</a> ({$mp3Size}{$mp 3B})";
        //$sermonFiles .= "<li>";
        //unset($brBob);
        $brBob = "0";
        $sermonFiles .= "<a style=\"font-weight: bold; color: rgb(255, 255, 255);\" href=\"$dirname {$_date}_{$_nam es}.mp3\">{$dat ed}</a> ({$mp3Size}{$mp 3B})";
        if($_values['pdf']) {
        $brBob = "1";
        $pdfSize = filesize("$dirn ame2{$_date}_{$ _names}.pdf");
        $pdfSize /= $sizeDivider; $pdfB = "KB";
        if($pdfSize > 100) { $pdfSize /= $sizeDivider; $pdfB = "MB"; }
        $pdfSize = round($pdfSize, 2);
        //echo ", <a href=\"$dirname 2{$_date}_{$_na mes}.pdf\">Note s</a> ({$pdfSize}{$pd fB})";
        $sermonFiles .= " &nbsp; ";// Space between text and next text
        $sermonFiles .= "<a style=\"font-weight: bold; color: rgb(255, 255, 255);\" href=\"$dirname 2{$_date}_{$_na mes}.pdf\">Note s</a> ({$pdfSize}{$pd fB})<br />";
        }
        if($_values['doc']) {
        $brBob = "1";
        $docSize = filesize("$dirn ame3{$_date}_{$ _names}.doc");
        $docSize /= $sizeDivider; $docB = "KB";
        if($docSize > 100) { $docSize /= $sizeDivider; $docB = "MB"; }
        $docSize = round($docSize, 2);
        //echo ", <a href=\"$dirname 3{$_date}_{$_na mes}.doc\">Note s</a> ({$docSize}{$do cB})";
        $sermonFiles .= " &nbsp; ";// Space between text and next text
        $sermonFiles .= "<a style=\"font-weight: bold; color: rgb(255, 255, 255);\" href=\"$dirname 3{$_date}_{$_na mes}.doc\">Note s</a> ({$docSize}{$do cB})<br />";
        } //echo($brBob."hh h ");
        if(!$brBob) { $sermonFiles .= "<br />"; }
        }

        $sermonFiles .= "<br /><br />";
        }
        }


        unset($date, $ext, $names, $parts, $udate);
        $names = array();
        $ziplist = glob("$dirname4 *.zip");
        foreach($ziplis t as $_zipfile) {
        // Split the path into individual parts.
        $parts = explode('/', $_zipfile);
        // This uses regular expressions to
        // split the file name on all dashes (-) and dots (.).
        list($series, $date, $ext) = preg_split('/[_\.]/is', end($parts));

        // Turn $date into timestamp
        $udate = strtotime($date );
        //echo("bob".$uda te."pop<hr>");

        // Store the file in the $names array.
        // Lets put timestamp in front of names?
        $names[$udate][$series][$date] = array('fake' => 'nothing');
        }
        //print_r($names) ;die();
        // Sort the dates
        // sort da array by key
        //ksort($names);
        ksort($names);
        // Go through the storage array and print every name
        foreach($names as $_udate => $_serie) {

        foreach($_serie as $_series => $_dates) {
        // Sort the dates
        // sort da array by key
        ksort($_serie);
        //print_r($_serie );

        // Print each date
        foreach($_dates as $_date => $_values) {

        $dated = $_date;
        // Replace all "-" with " "
        $dated = str_replace("-", " ",$dated);
        $zipSize = filesize("$dirn ame4{$_series}_ {$_date}.zip");
        //echo($zipSize." ");
        $zipSize /= $sizeDivider; $zipB = "KB";
        if($zipSize > 100) { $zipSize /= $sizeDivider; $zipB = "MB"; }
        //echo($zipSize." ");
        $zipSize = round($zipSize, 2);
        $sermonZips .= "<a style=\"font-weight: bold; color: rgb(255, 255, 255);\" href=\"$dirname 4{$_series}_{$_ date}.zip\">{$_ series} ({$dated})</a> ({$zipSize}{$zi pB})<br />";
        }
        }
        }
        $sermonZips .= "<br /><br />";


        echo("

        <div style=\"padding-right: 10px; background-color: rgb(68, 164, 212);\">
        <div style=\"font-weight: 700; color: rgb(255, 255, 255); text-align: right;\"><a style=\"font-weight: 700; color: rgb(255, 255, 255);\" href=\"javascri pt:history.back ()\">Back to previous page</a></div>
        <br />
        <span style=\"font-weight: bold; color: rgb(255, 255, 255);\">SERMON ARCHIVE</span><br />
        <span style=\"font-weight: bold;\"><br />
        For any CD or print copies of sermons, please contact Carol at the Church office between 8am and 1pm.<br />
        012 998 2877</span><br />
        <a style=\"color: rgb(255, 255, 255); font-weight: bold;\" href=\"mailto:c arol@eastside.o rg.za\">carol@e astside.org.za</a><br />
        <br />
        <table border=\"0\" width=\"100%\">
        <tbody>
        <tr>
        <td><span style=\"font-weight: bold; font-size: 20pt; color: rgb(255, 255, 255);\">MP3 DOWNLOADS:</span><br />
        </td>
        <td width=\"4%\"><b r />
        </td>
        <td><span style=\"font-weight: bold; font-size: 20pt; color: rgb(255, 255, 255);\">ZIP DOWNLOADS:</span></td>
        </tr>
        <tr>
        <td colspan=\"3\"> Please right click on the relevant link and select \"save target as\" or \"save link as\" to download the desired audio / zip file.</td>
        </tr>
        <tr>
        <td valign=\"top\"> <br />
        $sermonFiles
        </td>
        <td>&nbsp;<br />
        </td>
        <td valign=\"top\"> <br />
        <br />
        <br />
        $sermonZips
        </td>
        </tr>
        </tbody>
        </table>
        <hr style=\"width: 100%; height: 2px;\" />
        <br />
        <span style=\"font-weight: bold;\">For any CD or print copies of sermons, please contact Carol at the Church office between 8am and 1pm.<br />
        012 998 2877</span><br />
        <a style=\"color: rgb(255, 255, 255); font-weight: bold;\" href=\"mailto:c arol@eastside.o rg.za\">carol@e astside.org.za</a><br />
        </div> </div>
        ");


        /*
        //original code by Alti on bytes.com:
        $mp3list = glob("sermons/mp3/*.mp3");
        $names = array();
        foreach($mp3lis t as $_mp3file) {
        // Split the path into individual parts.
        $parts = explode('/', $_mp3file);

        // This uses regular expressions to
        // split the file name on all dashes (-) and dots (.).
        list($name, $date, $ext) = preg_split('/[_\.]/is', end($parts));

        // See if a PDF file exists
        $pdfPath = "serms/pdf/{$name}_{$date} .pdf";
        $pdfExists = file_exists($pd fPath);

        // Store the file in the $names array.
        $names[$name][$date] = array(
        'pdf' => $pdfExists
        );
        }
        // Go through the storage array and print every name
        foreach($names as $_name => $_dates) {
        // Sort the dates
        ksort($_dates);

        // Print the name
        echo "<div><strong>{ $_name}</strong><ul>";

        // Print each date, along with a link to the
        // Mp3 and the PDF (if any)
        foreach($_dates as $_date => $_values) {
        echo "<li>{$_dat e}: ",
        "<a href=\"serms/mp3/{$_name}_{$_dat e}.mp3\">Mp3</a>";
        if($_values['pdf']) {
        echo ", <a href=\"serms/pdf/{$_name}_{$_dat e}.pdf\">PDF</a>";
        }
        }

        // Print fotter
        echo "</ul></div>";
        }
        */
        ?>[/code]

        Comment

        Working...