On this page only the file containing the same number as the WEEK we're in +1, should be highlighted (aka: highlight the next week, the coming week)
Right now it highlights lots of weeks, starting with the current week and highlighting the rest of the availible weeks(files)... Any idea where I may have done a biig mistake, or just a stupid logical error?
Here's the code:
PHP Code:
<center><br><br> <!-- CENTER EVERYTHING ON THIS PAGE -->
<?PHP
$AllowedExtension=array('txt'); //**List Of FileExtensions You Allow To Show**\\
$FileCount=0;
$TheDir=".";
$DirectoryFiles=opendir("$TheDir"); //**The Directory, Where Your Files Are Stored**\\
$TheDate = date("d.F.Y"); //**The Current Date Today**\\
$TheTime = date("\k\l\ \ H:i"); //**The Current Time Right Now**\\
$ThisDay = date("D"); //**This Days Short Name; ex: Sun**\\
$WeekNumber=date("W"); //**The Current Week Number**\\
$NextWeekNumber=date("W"); //**The Next Weeks Number**\\
$CheckWeek="ThisWeek: " . $WeekNumber; //**Checks This Weeks Number**\\
$CheckNextWeek="NextWeek: " . $NextWeekNumber; //**Checks Next Weeks Number**\\
?>
<?PHP //**THIS WRITES THE TOP HEADER TEXT ON THE PAGE**\\
Echo "<h3><i><u>Week:</u></i> " . $WeekNumber . " @@ <i><u>Day:</u></i> " . $ThisDay . " @@ <i><u>Date:</u></i> " . $TheDate . " @@ <i><u>Time:</u></i> " . $TheTime . "</h3>";
Echo "The SpecialDay we're looking for is: <b>".$ThisDay."</b> and that should highlight the file containing this number: <b>".$NextWeekNumber."</b><br><br><br>";
?>
<?PHP
//**CHECKS ALL FILES IN DIRECTORY FOR ALLOWED EXTENSIONS AND ADD THEM TO THE ARRAY**\\
while($CurrentFileName = readdir($DirectoryFiles))
{ //while-start
if(in_array(strtolower(substr($CurrentFileName,-3)),$AllowedExtension))
{
$FileArray[]=$CurrentFileName;
Sort($FileArray);
Reset($FileArray);
$FileCount=$FileCount+1;
}
} //while-End
//**WHEN DONE CHECKING THE DIRECTORY AND ADDING FILENAMES TO THE ARRAY**\\
$TotalArrayFilenameCount=count($FileArray); //**Count of Filenames in the Array**\\
$FileListWidth=2; //**DEFINES HOW MANY FILES TO LIST PR ROW, BEFORE JUMPING TO NEXT LINE**\\
$FileListCounter=0; //**EMPTIES THE COUNTER FOR THE "HOW MANY FILES TO LIST PR ROW" HEHE**\\
//$FileListCounter=$FileListCounter-1;
//** USE THE COUNTED FILENAMES IN THE ARRAY TO PROCESS THE DIFFRENT FILENAMES AND OUTPUT SOME RESULT**\\
for($IncrementCount=0; $IncrementCount < $TotalArrayFilenameCount; $IncrementCount++){ //START THE "FOR" LOOP\\
//if($ThisDay=="Sun") <--ORIGINAL REMOVED FOR TEST PURPOSES //**CHECKS TO SEE IF IT IS THE SPECIAL DAY TODAY**\\
if($ThisDay==$ThisDay) //**CHECKS TO SEE IF IT IS THE SPECIAL DAY TODAY**\\
{
//**IF THIS IS THE SPECIAL DAY THAT WE ARE LOOKING FOR THEN DO SPECIAL PROCEDURES FOR THIS DAY AND NEXT WEEK**\\
//**SPECIAL**\\
$ToFindNow=$NextWeekNumber; //**PUT THIS WEEKS NUMBER INTO THE ToFindNow VARIABLE**\\
$ToLookNow=$FileArray[$IncrementCount]; //**THE ToLookNow VARIABLE GETS INFO FROM THE ARRAY RECORD EQUAL TO IncrementCount VARIABLE**\\
echo "SpecialDay";
}
else
{
//**THIS IS JUST ANY OTHER DAY THAN THE SPECIALDAY, DO NORMAL PROCEDURES FOR THIS WEEK**\\
$ToFindNow=$WeekNumber; //**PUT THIS WEEKS NUMBER INTO THE ToFindNow VARIABLE**\\
$ToLookNow=$FileArray[$IncrementCount]; //**THE ToLookNow VARIABLE GETS INFO FROM THE ARRAY RECORD EQUAL TO IncrementCount VARIABLE**\\
echo "NormalDay";
}
ereg($ToFindNow, $ToLookNow, $Matches); //**CHECK THE TWO STRINGS TO SEE IF THEY MATCH, AND PUT THE RESULT INTO ARRAY Matches**\\
//if($Matches[0] == $ToFindNow)
//if (In_String($ToFindNow,$ToLookNow,1))
//**SETS THE DISPLAY OF FIlENAMES ON THE PAGE TO ROWS OF THREE FILES PR ROW**\\
$FileListCounter=$FileListCounter+1;
if ( $FileListCounter==$FileListWidth ) {$FileListCounter=0; echo"<br><br>";}
} //ENDS THE "FOR" LOOP\\
?>
<br><br>THIS SHOULD ONLY HIGHLIGHT <b>ONE</b> FILE... RIGHT NOW IT HIGHLIGHTS MANY FILES <!-- END -->
I've also added the file "index.php" that contains the whole code as an attachment...
Thanks a lot for your help...!!!
Last edited by alexdata; Sep 24th, 2009 at 04:50 AM.
*************** Please use [highlight=vb]..your code.. [/highlight] when posting code!
When you have received the working answer to your question,
please mark it as *SOLVED* + Your Questions Title ...using your Thread's Tool menu.
Also try to point out what answer made it work for you, or edit your first post to contain a quote of the correct answer...
Please Answer All Questions With Working Code Examples...