Assistance in Upgrading Simple Calendar Script to Include Links to Existing Files

  • Thread starter Thread starter Anonymous
  • Start date Start date
A

Anonymous

Guest
If you use something towards the beginning to create a list of files in the directory, like...
Code:
$files = scandir('data');

then when creating each cell, put something which checks if the file exists and adds a link tag in as well. Something like...
Code:
    	$fileName = sprintf("%02d%02d%02d.mp3", $cYear % 100, $cMonth, $i - $startday + 1);
    	$fileFound = false;
    	if ( in_array($fileName, $files) == true )	{
    		echo '<a href="data/'.$fileName.'">';
    		$fileFound = true;
    	}
    	echo ($i - $startday + 1) ; 
    	if ( $fileFound == true )	{
    		echo '</a>';
    	}
You can add anything else like colouring however you want to, but the main logic should be there.
 
Back
Top