Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <pre><code>GROUP BY 10800*FLOOR(`time`/10800) </code></pre> <p>However if you've got records (say) at 2:59 and 3:01, these will be reported as 2 seperate records in the output. If you want to measure contiguous runs, then you'll need to do something similar to your current code - however you can store the results in the DB so as not to calculate them again - just add a new column which references the row designated as the start of the session:</p> <pre><code>ALTER TABLE besucher ADD COLUMN session_start INTEGER; </code></pre> <p>Then....</p> <pre><code>$limit = 3 /*std*/ * 60 /*min*/ * 60 /*sek*/; $since=(integer)(file_get_contents('lastrun'))-$limit; $besucher_query = mysql_query('SELECT ip, `time`, `agent` FROM `besucher` WHERE `time`&gt;$since ORDER BY agent, ip, `time` ASC'); while($besucher = mysql_fetch_array($besucher_query)) { $newtime = $besucher['time']; $newagent = $besucher['agent']; $newip = $besucher['ip']; if ($newagent!=$oldagent || $newip &lt;&gt; $oldip || $newtime&gt;$oldtime+$limit || $newtime&lt;$oldtime) { $sessionstart=$newtime; } $newagent=mysql_real_escape_string($newagent); mysql_query( "UPDATE besucher SET session_start=$sessionstart WHERE time=$newtime AND ip=$newip AND agent='$newagent'" ); $oldtime = $besucher['time']; $oldagent = $besucher['agent']; } file_put_contents('lastrun', $oldtime); </code></pre> <p>Then you can get the number of sessions from (for example)....</p> <pre><code>SELECT COUNT(*) FROM (SELECT DISTINCT ip, agent, session_start FROM bessucher WHERE time BETWEEN $a AND $b) ilv </code></pre> <p>Bu a simpler solution is to use session management in your code and populate this immediately.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload