dimanche 4 décembre 2016

running an if statement within a foreach PDO

When I added the if statement that compares the value of times stored in a table with current time, PHP will throw an error. Could not find solution anywhere. Your help is appreciated. here is the code:

<?php
//All database times that are 1 hour before stating will be locked in browser not able to reserve any more
$currtime= date("h:i");

foreach ($pdo->query($sql) as $row ) {
    echo '<tr>';
    if ( $row['time']-$currtime=<-1) {
        echo '<td>'.$row['time']='passed'.'</td>'
    };
    else {
        echo '<td>'. $row['time'] . '</td>';
    }
    //the following part is just so you know what follows in my code within the loop

    if($row[$selected_day]=='available') { 
        echo '<td>'. '<a href="read.php?id='.$row['id'] . '&s_t_id='.$row['schd_tut_id'].'&dat='.$selected_day  .'">available</a>';
    } else {
        echo '<td>'. $row[$selected_day] . '</td>';
    }
}
?>

Aucun commentaire:

Enregistrer un commentaire