m.adel Posted September 17, 2008 Share Posted September 17, 2008 Hi its easy to fix but i'm noob i know that .. look this script is a part from my project , copy the code and put it in blanck php file and test it u'll know the problem .. cuz i'm not good with the explaining .. thanks <?php $myPeriod = new medosPeriod(); $myPeriod->showPeriod(2008,9,20,"Period One"); $myPeriod->showPeriod(2008,9,30,"Period Two"); $myPeriod->showPeriod(2008,10,10,"Period Three"); $myPeriod->showPeriod(2008,10,20,"Period Four"); $myPeriod->showPeriod(2008,10,30,"Period Five"); $myPeriod->showPeriod(2008,11,9,"Period Six"); $myPeriod->showPeriod(2008,11,19,"Period Seven"); $myPeriod->showPeriod(2008,11,29,"Period Eight"); $myPeriod->showPeriod(2008,12,8,"Period Nine"); $myPeriod->showPeriod(2008,12,18,"Period Ten"); $myPeriod->showPeriod(2008,12,28,"Period Eleven"); $myPeriod->showPeriod(2009,1,8,"Period Twilve"); $myPeriod->showPeriod(2009,1,18,"Period Thirteen"); $myPeriod->showPeriod(2009,1,28,"Period Fourteen"); $myPeriod->showPeriod(2009,2,7,"Period Fifteen"); $myPeriod->showPeriod(2009,2,17,"Period Sixteen"); $myPeriod->showPeriod(2009,2,27,"Period Seventeen"); $myPeriod->showPeriod(2009,3,9,"Period Eighteen"); $myPeriod->showPeriod(2009,3,19,"Period Nineteen"); $myPeriod->showPeriod(2009,3,29,"Period Twintey"); $myPeriod->showPeriod(2009,4,8,"Period Twintey One"); $myPeriod->showPeriod(2009,4,18,"Period Twintey Two"); $myPeriod->showPeriod(2009,4,28,"Period Twintey Three"); $myPeriod->showPeriod(2009,5,8,"Period Twintey Four"); class medosPeriod{ function showPeriod($year,$month,$day,$period){ $fday = getdate(mktime(0,0,0,$month,$day,$year)); $lday = getdate(mktime(0,0,0,$month,$day+10,$year)); echo '<table class="month">'; echo ' <tr><th colspan="10">'.$fday['month']." - ".$fday['year']." ( ".$period." )</th></tr>"; echo ' <tr class="days"><td>Day 1</td><td>Day 2</td><td>Day 3</td><td>Day 4</td><td>Day 5</td><td>Day 6</td><td>Day 7</td><td>Day 8</td><td>Day 9</td><td>Day 10</td></tr>'; echo ' <tr>'; for($i=$fday['mday'];$i<$lday['mday'];$i++){ echo "<td$class>$i</td>"; } echo ' </tr>'; echo ' </table>'; } } ?> Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted September 17, 2008 Share Posted September 17, 2008 The problem occurs when your period spanned a month end/start. Try this instead: <?php class medosPeriod{ function showPeriod($year,$month,$day,$period){ $st = strtotime($year . '-' . $month . '-' . $day); $end = $st + 864000; // 86400 seconds in a day echo '<table class="month">'; echo ' <tr><th colspan="10">'. date('F - Y',$st) . " ( ".$period." )</th></tr>"; echo ' <tr class="days"><td>Day 1</td><td>Day 2</td><td>Day 3</td><td>Day 4</td><td>Day 5</td><td>Day 6</td><td>Day 7</td><td>Day 8</td><td>Day 9</td><td>Day 10</td></tr>'; echo ' <tr>'; for($i=$st;$i<$end;$i+=86400){ echo "<td$class>" . date('j',$i) . "</td>"; } echo ' </tr>'; echo ' </table>'; } } ?> Ken Quote Link to comment Share on other sites More sharing options...
m.adel Posted September 17, 2008 Author Share Posted September 17, 2008 yea thanks so much that was so quick Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.