gibigbig Posted March 3, 2011 Share Posted March 3, 2011 I'd like to make an sql request every x seconds with php. is it possible? Quote Link to comment https://forums.phpfreaks.com/topic/229446-can-you-make-an-sql-every-x-seconds-with-php/ Share on other sites More sharing options...
jcbones Posted March 3, 2011 Share Posted March 3, 2011 Yes. Depending on your server, you can use crontab to call a specific script, or command line. Or, you can use task manager. Quote Link to comment https://forums.phpfreaks.com/topic/229446-can-you-make-an-sql-every-x-seconds-with-php/#findComment-1182179 Share on other sites More sharing options...
kenrbnsn Posted March 3, 2011 Share Posted March 3, 2011 I believe the smallest time increment you can get with a Linux cronjob is 1 minute. Ken Quote Link to comment https://forums.phpfreaks.com/topic/229446-can-you-make-an-sql-every-x-seconds-with-php/#findComment-1182180 Share on other sites More sharing options...
gibigbig Posted March 3, 2011 Author Share Posted March 3, 2011 how exactly do i go about doing that with php? I plan to do something similar to facebook notifications (the little popup in the bottom left), i have the javascript down, and i got the database to update itself how i want, all i need is to connect them by adding something that will check the database every 10 seconds and activate my javascript to display it. can any of you give me some actual code? i'd find that way more useful than instructions. Quote Link to comment https://forums.phpfreaks.com/topic/229446-can-you-make-an-sql-every-x-seconds-with-php/#findComment-1182183 Share on other sites More sharing options...
doddsey_65 Posted March 3, 2011 Share Posted March 3, 2011 on my site to check if a user has an email i query the database in a file called initilize.php which is called by header.php, which is called by every file. This means that every time the page is reloaded this query runs to check if there are new emails. maybe try something along those lines. Quote Link to comment https://forums.phpfreaks.com/topic/229446-can-you-make-an-sql-every-x-seconds-with-php/#findComment-1182189 Share on other sites More sharing options...
kenrbnsn Posted March 3, 2011 Share Posted March 3, 2011 You can do that using Javascript with an AJAX call back to your PHP script to do the actual DB queries. Ken Quote Link to comment https://forums.phpfreaks.com/topic/229446-can-you-make-an-sql-every-x-seconds-with-php/#findComment-1182193 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.