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):
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
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";
*/
?>
Thanks so much
SMiLE
Comment