SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Zealot TCJeter's Avatar
    Join Date
    Jun 2002
    Location
    Anchorage, AK
    Posts
    187
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Class results are returned, but un-styled...

    Hello all.
    I have a basic class setup that returns data from MySQL for day-of-the-week combinations (i.e.-class shedules: 'Mon, Wed., Fri.'). The data from the row shows up in my styled 'div', but it's not styled the same as the rest of the data.

    I'm brand new to building functions within classes, so if you spot any inefficiencies in my code please feel free to advise. The function 'getDays' (within the 'dataSort' class) is simply a switch that will return day-of-the-week text combinations based on the 1/0, true/false data in the row. Example: 10101 = 'Mon, Wed., Fri.'.

    Any ideas why this is returned 'un-styled'?? I do get valid data as intended (no errors), but I can't figure this one out.

    Class:
    PHP Code:
    class dataSort {
       
           function 
    getDays($days) {
           
               switch (
    $days) { 
                       case 
    '10000':
                       echo 
    'Mon.';
                       break;
                       case 
    '11000':
                       echo 
    'Mon., Tue.';
       
    //....and so on....25 combinations for 5 days of the week (5 X 5)... 
    results page:
    PHP Code:
    if (isset($result)) {
           
           
    $rowcount 0//Start row count for color switch
           
             
    while ($row $connector->fetchArray($result)){ // start 'while' loop for repeating row data
             
    $row_color = ($rowcount 2) ? $color1 $color2// switch color - taken from 'format.vars.inc'
               
                 
    echo '<div class="row" style="background-color:'.$row_color.'">'// start row
                  
    echo '<div class="fieldname">Course title:</div>';
                  echo 
    '<div class="fieldvalue">'.$row['title'].'</div>';
                   echo 
    '</div>'// close 'row'
                   
                 
    echo '<div class="row" style="background-color:'.$row_color.'">'// start row
                  
    echo '<div class="fieldname">Section number:</div>';
                  echo 
    '<div class="fieldvalue">'.$row['section_num'].'</div>';
                   echo 
    '</div>'// close 'row'
                   
                 
    echo '<div class="row" style="background-color:'.$row_color.'">'// start row
                  
    echo '<div class="fieldname">Course number:</div>';
                  echo 
    '<div class="fieldvalue">'.$row['course_num'].'</div>';
                   echo 
    '</div>'// close 'row'
                   
                 
    echo '<div class="row" style="background-color:'.$row_color.'">'// start row
                  
    echo '<div class="fieldname">Course days:</div>';
                  echo 
    '<div class="fieldvalue">'.$days->getDays($row['days']).'</div>';
                   echo 
    '</div>'// close 'row'
       
       //....and so on... 
    Any help appreciated - Thanks!
    -TC

  2. #2
    SitePoint Zealot TCJeter's Avatar
    Join Date
    Jun 2002
    Location
    Anchorage, AK
    Posts
    187
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Case solved.
    In the class I was using an 'echo' for the value rather than 'return'.
    I was placing the echoed text as an object rather than calling the return value into the 'div'. At least that's how I understand it in hind-sight.

    -TC


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
  •