SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Enthusiast
    Join Date
    Jul 2002
    Posts
    28
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question display calendar

    I've got a situation where I have atleast two exams scheduled in a week, which makes it approx eight exams in a month. I've entered all these dates in the DB. I would like to display these dates in monthly calendar format, where only the exam dates are displayed as a link (and the rest are not).

    I've managed to display the dates appropriately under the respective days but displaying them in an weekly order is quite difficult ... I can't get the logic right ... I've attached a screeny for your reference.

    your help is appreciated ...
    Attached Images Attached Images

  2. #2
    SitePoint Enthusiast
    Join Date
    Jul 2002
    Posts
    28
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The attached image is what I would like to achieve
    Attached Images Attached Images

  3. #3
    SitePoint Enthusiast
    Join Date
    Jul 2002
    Posts
    28
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Did I ask a very difficult question or what

    *and I did search the forum but I could not find anything close to what I need

  4. #4
    SitePoint Wizard mark_W's Avatar
    Join Date
    Mar 2004
    Location
    West Midlands, United Kingdom
    Posts
    2,631
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Any chance you can maybe post the code, its hard to try and help otherwise.

    Mark.

  5. #5
    SitePoint Enthusiast
    Join Date
    Jul 2002
    Posts
    28
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    *relief

    What I'm doing is - I retrieve a record and then check if the day is between SAT - WED. Then I store each date that falls on a SAT in an array for that particular day. In this way all exams that are scheduled for say Saturday are in the array Saturday[]. Then I print out these arrays (SAT-WED) one after the other, which is why they don't appear in weekly order. I can't seem to get the logic working ...

    PHP Code:
           <?php
          
    //include the necessary files
          
    include 'header.htm';
          include 
    'inc.global.php';
          
          
    //Initializing necessary variables
          
    $Saturday[] = NULL;
          
    $Sunday[] = NULL;
          
    $Monday[] = NULL;
          
    $Tuesday[] = NULL;
          
    $Wednesday[] = NULL;
          
          
    ?>
          <table width="85%"  border="0" align="center">
            <tr>
         <td width="6%"><img src="images/arrow_green.gif" width="44" height="42" align="top"></td>
              <td width="89%">&nbsp;</td>
         <td width="5%"><img src="images/table_padding.gif" width="44" height="42" align="top"></td>
            </tr>
            <tr>
              <td>&nbsp;</td>
              <td><p class="myHeading">Exam Schedule</p>
             <p align="center">Month: <a href="?month=1">Jan</a> | <a href="?month=2">Feb</a> | <a href="?month=3">Mar</a> | <a href="?month=4">Apr</a> | <a href="?month=5">May</a> | <a href="?month=6">Jun</a> | <a href="?month=7">Jul</a> | <a href="?month=8">Aug</a> | <a href="?month=9">Sep</a> | <a href="?month=10">Oct</a> | <a href="?month=11">Nov</a> | <a href="?month=12">Dec</a> </p>
                  <table width="85%"  border="0" align="center">
                    <tr>
                      <td align="center" bgcolor="#E9E9E9"><div align="center">
                  <table width="100%" border="0" align="center" cellpadding="3" cellspacing="1">
                     <tr bgcolor="#CECEFF">
                      <th height="12">Saturday</th>
                      <th height="12">Sunday</th>
                      <th height="12">Monday</th>
                      <th height="12">Tuesday</th>
                      <th height="12">Wednesday</th>
                          </tr>
                          <tr bgcolor="#FFFFFF" valign="top">
        <?php
     $sessionQuery 
    'SELECT `sessionID`, DATE_FORMAT(`date`, \'%d-%b-%y\') AS `date`, DATE_FORMAT(`time`, \'%h:%i %p\') AS `time`, DAYNAME(`date`) AS `day` FROM `schedule`';
          
          
        
    //Retrieve the schedule from the database
     
    $sessionQueryResult = @mysql_query($sessionQuery) or die('<div class="error">Invalid query: ' mysql_error().'/<div>');
           if((
    mysql_num_rows($sessionQueryResult)) < 1)
         { echo 
    '<tr><td colspan=5><div class="error" align="center">No exams scheduled for this month</div></td></tr>'; }
             else
               {
                   while (
    $row mysql_fetch_array($sessionQueryResultMYSQL_ASSOC))
                              {
                                  switch(
    $row['day'])
                             {
                           case (
    $row['day'] == 'Saturday'):
                           
    $Saturday[] = '<a href=signup.php?id='.$row['sessionID'].'>'.$row['date'].'<br>'.$row['time'].'</a><br><br>';
                           break;
                             
                           case (
    $row['day'] == 'Sunday'):
                           
    $Sunday[] = '<a href=signup.php?id='.$row['sessionID'].'>'.$row['date'].'<br>'.$row['time'].'</a><br><br>';
                           break;
                             
                           case (
    $row['day'] == 'Monday'):
                           
    $Monday[] = '<a href=signup.php?id='.$row['sessionID'].'>'.$row['date'].'<br>'.$row['time'].'</a><br><br>';
                           break;
                             
                           case (
    $row['day'] == 'Tuesday'):
                           
    $Tuesday[] = '<a href=signup.php?id='.$row['sessionID'].'>'.$row['date'].'<br>'.$row['time'].'</a><br><br>';
                           break;
                             
                           case (
    $row['day'] == 'Wednesday'):
                           
    $Wednesday[] = '<a href=signup.php?id='.$row['sessionID'].'>'.$row['date'].'<br>'.$row['time'].'</a><br><br>';
                           break;
                             } 
    //switch
                         
    //while
                              
                          
    echo '<td width=20%><div align="center">';
                          for(
    $i=0$i<count($Saturday); $i++)
                           {    
                           echo 
    $Saturday[$i];
                             }
                          echo 
    '</div></td>';
                             
                          echo 
    '<td width=20%><div align="center">';
                          for(
    $i=0$i<count($Sunday); $i++)
                       {    echo 
    $Sunday[$i]; }
                          echo 
    '</div></td>';
                             
                          echo 
    '<td width=20%><div align="center">';
                          for(
    $i=0$i<count($Monday); $i++)
                           {    
                           echo 
    $Monday[$i];
                             }
                          echo 
    '</div></td>';
                             
                          echo 
    '<td width=20%><div align="center">';
                          for(
    $i=0$i<count($Tuesday); $i++)
                           {    
                           echo 
    $Tuesday[$i];
                             }
                          echo 
    '</div></td>';
                             
                          echo 
    '<td width=20%><div align="center">';
                          for(
    $i=0$i<count($Wednesday); $i++)
                           {    
                           echo 
    $Wednesday[$i];
                             }
                          echo 
    '</div></td>';
                    
    ?>
                          </tr>
                        </table>
                      </div></td>
                    </tr>
                  </table>
                  <p>  
                <div class="redAlert">
             <div align="center">Note: If you are not a registered candidate, you cannot sit for the exam.</div>
                </div>
              </td>
              <td>&nbsp;</td>
            </tr>
          </table>
          <?php
          
    include 'footer.htm';
          
    ?>


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •