Page 1 of 1

example of event to fetch the data from a table on every 5

Posted: Fri Jan 07, 2011 12:08 am
by kaif
I created the event for the select query, it successfully running on mysql.I have the problem that how to run this on the window for every 1 hour.

this is my code:

event CREATE EVENT `kaif`
ON SCHEDULE EVERY 5 SECOND
do
SELECT * FROM test.temp2;

this code is running successfully on mysql but how to retrive (fetch) the result and display on the browser

please give me the solution

Thanks in advance from Kaif

Re: example of event to fetch the data from a table on every

Posted: Fri Jan 07, 2011 12:42 am
by social_experiment
You have to wrap you query in mysql_query(), then see if the query is successful

Code: Select all

<?php if ($query) ?>
Once that is achieved use a function like mysql_fetch_array() and use a while loop to display the information to the browser.

Re: example of event to fetch the data from a table on every

Posted: Fri Jan 07, 2011 4:06 am
by Phoenixheart
There are 2 questions here:

- How to fetch the data: take a look at mysql_ functions.
- How to run the script every one hour: use cron jobs.