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:
results page: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)...
Any help appreciated - Thanks!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...
-TC




Bookmarks