Find the last visit by teacher and show the rest of columns in MySql
You need to join all the teacher's last visit_time value against the whole visits table

SELECT B.* FROM
(
    SELECT teacher,MAX(visit_time) visit_time
    FROM visits GROUP BY teacher
) A INNER JOIN visits B USING (teacher,visit_time);


Based on this query, you should also add the following index

ALTER TABLE visits ADD INDEX teacher_visit_time_ndx (teacher,visit_time);


Give it a Try !!!