Update mysql query if user closed his Broswer
<p>If user logged in then it's show status is "ON" because of i run the query to show that the user is now ONLINE:    </p>

<p><strong>Online:</strong></p>

<pre><code>$sqlonline = mysql_query("INSERT INTO useronline VALUES('$_SESSION[id]', '$uname', '$ip', 
'$time', '', 'ON')");
</code></pre>

<p>And If user is logged out then I update the query to show that the user is OFFLINE</p>

<p><strong>Offline</strong></p>

<pre><code>$q=mysql_query("UPDATE useronline SET status = 'OFF',  time_out  = '$time' WHERE 
session_id ='$_SESSION[id]'");
</code></pre>

<p>Well, My question.. Is there any way to update the query to status = <strong>'OFF'</strong> if user closed his/her browser? Now it's show User is Now <strong>ONLINE</strong> if user closed the browser. I want if user closed the browser then it's show user is now <strong>"OFFLINE"</strong> </p>

<p>Can anyone give me a idea!<br>
Sorry my bad english:(</p>
