My Sql and Asterisk queue_log

Hi Everyone

Just got a problem Im having.

We’ve linked Mysql to pull query_log from asterisk and created a website to display the data such as, Inbound Hold time , Calls waiting, available agents etc. The problem is that once a call is answered it still shows the call as waiting and still counts the seconds holding time even though the call was answered and agent completed call and hangup. Please assist as to how to resolve this error as it does not seem to update mysql as to whether the call was answered or still in queue or hangup and give accurate info on calls waiting and answered calls.