antonyfal Posted January 11, 2012 Share Posted January 11, 2012 Hi. I have a query that determines if user is online/offline. Works perfectly when page loads. I want to change to auto run query every X seconds. NOTES: - The query is on a .php page with multiple other queries. -IF it is possible to still run the query with-in this page? or make a separate file and include in an iframe? i would like to avoid the iframe and just $output the result of query every X seconds. Here is my $query code: $query = "SELECT `manager_id` FROM #__profiles_xref WHERE profileid = '$profid'"; $onofflineid=doSelectSql($query,1); foreach ($onofflineid as $isonoffline){ $profmanagerid=$isonoffline->manager_id; } $query = "SELECT `session_id` FROM table_session WHERE userid = '$propmanagerid'"; $onofflinestatus=doSelectSql($query,1); if (count($onofflinestatus)>0) { $output['PROPSTATUS']='Online'; } else { $output['PROPSTATUS']='Offline'; } Quote Link to comment https://forums.phpfreaks.com/topic/254792-execute-query-ever-x-seconds/ Share on other sites More sharing options...
trq Posted January 11, 2012 Share Posted January 11, 2012 You would need to schedule a job to execute your script. Look into cron. Quote Link to comment https://forums.phpfreaks.com/topic/254792-execute-query-ever-x-seconds/#findComment-1306434 Share on other sites More sharing options...
kickstart Posted January 11, 2012 Share Posted January 11, 2012 Hi As above, or if you want the details output to update a users page then maybe put it in a small script to be used for an AJAX call. All the best Keith Quote Link to comment https://forums.phpfreaks.com/topic/254792-execute-query-ever-x-seconds/#findComment-1306453 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.