mardi 29 décembre 2015

Mess with if php

Hi so I am trying to make a function which actually detects the time and depends on date(H); shows what courses and some other info happen right now.

$holidays = false;
//$hour = date('H');
 $hour = "11"; //Changed it to test the code

function classes()
{
    if ($holdays == false) //Are we on holidays? No
    {
        if($hour > "9" && $hour < "21") //University working hours? yes
        {   
            if ($hour = "10") //Hour 10? classes below
            { 
                echo "<tr>";
                    echo '<th class="course-title"><a href="course.html">...</a></th>';
                    echo '<th class="course-category"><a href="">...</a></th>';
                    echo "<th>...</th>";
                    echo "<th>...</th>";
                    echo "<th>...</th>";
                echo "</tr>";
                //Another Class
                echo "<tr>";
                    echo '<th class="course-title"><a href="course.html">...</a></th>';
                    echo '<th class="course-category"><a href="">...</a></th>';
                    echo "<th>...</th>";
                    echo "<th>...</th>";
                    echo "<th>...</th>";
                echo "</tr>";
               //Another Class
                echo "<tr>";
                    echo '<th class="course-title"><a href="course.html">...</a></th>';
                    echo '<th class="course-category"><a href="">...</a></th>';
                    echo "<th>...</th>";
                    echo "<th>...</th>";
                    echo "<th>...</th>";
                echo "</tr>";
            }
            else{ //Hour not 10?
                echo "No classes right now.";
            }
        }
        else{ //Not working hours?
            echo "University closed at this time.</br>";

        }
    }
    else{ //Vacation?
            echo "University closed for vacation!";
    } 

}

So I setted $hour value to 11 so it will pass the first two ifs successfully and I expect that it will echo that there are no classes right now, but it returns that university is closed at this time. I may also mess up the } on the code.

PS: I know i am using to many echos I am not that experienced yet to go with strings

Aucun commentaire:

Enregistrer un commentaire