<?php
     //update troubleticket with the latest log entry for that ticket
     $query = "SELECT  troubleticketid FROM troubleticket_log";
     $result = mysql_query($query) or die("ERROR:".$query);
     while(list($troubleticketid) = mysql_fetch_row($result))
     {
        $query2 = "SELECT  mydatetime FROM troubleticket_log WHERE troubleticketid=$troubleticketid ORDER BY mydatetime DESC LIMIT 1";
        $result2 = mysql_query($query2) or die("ERROR:".$query2);
        list($lastdatetime) = mysql_fetch_row($result2);

      	$query3 = "UPDATE troubleticket SET lastlog_datetime='$lastdatetime' WHERE id='$troubleticketid'";
        mysql_query($query3) or die("ERROR:".$query3);
     }
?>
