SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Wizard billy_111's Avatar
    Join Date
    Jul 2009
    Posts
    1,683
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How can i remove the border

    Hey,

    I am trying to only show a dotted border on this page, but not show the border it the result is the last row.

    If you look at this page:

    http://www.glofamily.com/glo/fitness-courses/

    You can see 2 courses on Monday and Wednesday, but on Monday there are 2 courses and i don't want to show the bottom border on the last course..

    This is my code, is there a way i can check to see if the row is the last one and based on that show/don't show a border?

    PHP Code:
    <? $courses Course::selectByCurrentWeek('3'); ?>

                    <table>
                    
                    <tr style="height:40px">
                    <th class="paddingleft10px">Class</th>
                    <th class="paddingleft10px">Time</th>
                    <th class="paddingleft10px">Location</th>
                    </tr>
                    
                      <?
                      $curdate 
    "";
                    while(
    $row mysql_fetch_array($courses)){
                    
    $date $row['date'];
                    
    $date strtotime($date);
                    
    $day date('l',$date);
                    
    $time date("H:i",$date);
                    
                    
    $startdate $row['startdate'];
                    
    $startdate strtotime($startdate);
                    
    $starttime date("H:i",$startdate);
             
                    
    $enddate $row['enddate'];
                    
    $enddate strtotime($enddate);
                    
    $endtime date("H:i",$enddate);

                    if (
    $curdate != $day) {
                      echo 
    "<tr class='day'><th style='padding-left:10px; width:400px'>$day</th><th>&nbsp;</th><th style='width:140px'>&nbsp;</th></tr>";
                      
    $curdate $day;
                    }
                    
                    if (
    $curdate != $day) {
                      echo 
    "<tr class='day'><th style='padding-left:10px; width:400px'>$day</th><th>&nbsp;</th><th style='width:140px'>&nbsp;</th></tr>";
                      
    $curdate $day;
                    }

                    echo 
    "<tr><td><a href=\"".$_SERVER['SERVER_NAME'].$sitename."view-courses/?ID=$row[ID]&?=$row[ID]\">".$row['title']."</a></td><td>$starttime - $endtime</td><td>$row[location]</td></tr>";
                    }
                    
    ?>    
                     </table>
    Any ideas?

    Thanks again
    Software Engineer ASP, ASP.NET, VB, PHP

    Kind regards
    Billy

  2. #2
    SitePoint Wizard billy_111's Avatar
    Join Date
    Jul 2009
    Posts
    1,683
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Sorry i have just realized i have this line twice:

    PHP Code:
       if ($curdate != $day) {
                      echo 
    "<tr class='day'><th style='padding-left:10px; width:400px'>$day</th><th>&nbsp;</th><th style='width:140px'>&nbsp;</th></tr>";
                      
    $curdate $day;
                    } 
    Ignore the second repeated lines. I basically want to show a bottom border only if the row is not the last row, so if i have 3 rows returned, i want to show a bottom border on the first and second but not the third.

    I set the border in the css like so:
    #courses-table td{padding:4px 9px 6px 12px;border-bottom:1px dotted;}
    Any ideas how i can do this?
    Software Engineer ASP, ASP.NET, VB, PHP

    Kind regards
    Billy

  3. #3
    SitePoint Enthusiast
    Join Date
    Mar 2010
    Location
    Surrey, UK
    Posts
    84
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,

    This might not be the best way but you could iterate through the sql results and create an array of the courses, eg:

    Code:
    Array
    (
         [Monday] => Array
            (
                [0] => Array
                    (
                        [Name] => This is a test
                        [Time] => 04:15 - 00:00
                        [Location] => Somewhere
                    )
    
                [1] => Array
                    (
                        [Name] => This is a test 2
                        [Time] => 04:15 - 00:00
                        [Location] => Somewhere
                    )
    
            )
    
        [Wednesday] => Array
            (
                [0] => Array
                    (
                        [Name] => This is a test
                        [Time] => 03:20 - 00:00
                        [Location] => Somewhere
                    )
    
            )
    
    )
    Then use sizeof($arrayname['Monday']) to get the number of courses for each day and on the last one, remove the border.

    But as I say there may be a better way...

  4. #4
    SitePoint Wizard billy_111's Avatar
    Join Date
    Jul 2009
    Posts
    1,683
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hey,

    Thanks for your reply. Can you maybe show an example of how i could do this with the code i have if possible?

    Thanks again
    Software Engineer ASP, ASP.NET, VB, PHP

    Kind regards
    Billy

  5. #5
    SitePoint Enthusiast
    Join Date
    Mar 2010
    Location
    Surrey, UK
    Posts
    84
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    How about something like this? Note: for the purposes of this I've added an extra column from the database called 'day' which would be yyyy-mm-dd

    PHP Code:
    <?php
     $courses 
    Course::selectByCurrentWeek('3'); ?>

     <table>
     
     <tr style="height:40px">
     <th class="paddingleft10px">Class</th>
     <th class="paddingleft10px">Time</th>
     <th class="paddingleft10px">Location</th>
     </tr>
     
       <?php
     $coursedata 
    = array();
     while(
    $row mysql_fetch_array($courses)){
      
    $coursedata[$row['day']][] = array('date' => $row['date'], 'id' => $row['id'], 'title' => $row['title'], 'location' => $row['location'], 'startdate' => $row['startdate'], 'enddate' => $row['enddate']);
     }
                                                                    
     foreach (
    $coursedata AS $day => $value) {
      
    $date $day;
      
    $date strtotime($date);
      
    $day date('l',$date);
                                                                        
      echo 
    "<tr class='day'><th style='padding-left:10px; width:400px'>$day</th><th>&nbsp;</th><th style='width:140px'>&nbsp;</th></tr>";

       
    $x=0; foreach ($value AS $k => $v) { $x++;
       
    $time date("H:i",$v['date']);
     
       
    $startdate $v['startdate'];
       
    $startdate strtotime($startdate);
       
    $starttime date("H:i",$startdate);
             
       
    $enddate $v['enddate'];
       
    $enddate strtotime($enddate);
       
    $endtime date("H:i",$enddate);

       echo 
    "<tr";
       if (
    sizeof($value) == $x) { echo ' class="noborder"'; }
       echo 
    "><td><a href=\"".$_SERVER['SERVER_NAME'].$sitename."view-courses/?ID=".$v['id']."&?=".$v['id']."\">".$v['title']."</a></td><td>".$v['starttime']." - ".$v['endtime']."</td><td>".$v['location']."</td></tr>";
      }
        }

     
    ?>    

      </table>

    I should also add I haven't tested this


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
  •