I have a database which i created via PHPmyadmin. And I have problem with the time columns/calculation.
table name = course
..course_name | section_ID | Dr_ID | time_start | time_end | location
...................................| 10:00:00 | 10:20:00 < //i but the
value like this
And the type of (| time_start | time_end |) = Time < //like this in PHPmyadmin
And my query doesn’t work. I guess the problem is .time(). in the query:
$query2 = "SELECT location FROM sections where Dr_ID = 1
AND time_start <= ".time()." and time_end > ".time();
The
time()function returns a unix timestamp, you *time_start* field seems to be a mysql TIME type you need to convert one of them to be able to make a proper comparison.You can use
date("H:i:s",time())instead oftime(), which might get you what you wantOr you need to convert your *time_start* *time_end* fields to unix timestamp UNIX_TIMESTAMP() – you will need to concatenate the date in front of your *time_start*.