How to create event for select statement

Hi

All

How to create the event which can select the records from a table on every five seconds.

Please help me

Thanks

MD.Samiuddin

You can use setInterval to send an ajax request to the server to get the records you need at your required time interval.

will you please give me the code because i don’t know ajax

Thanks

You could use a scheduled task!

Which server side scripting are you using?

The query is working on insert and delete statements but it is not working on select statements.:frowning:

Hi maaz, welcome to SitePoint.

Your queries will be different for the Insert, Delete and Select operations, you cannot compare them.

Try a simple select statement and debug that, something like:


SELECT NOW() AS 'now';

I am using php script

i want to write the event on select query .this is my code

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

the above code is not working ,why

this is urgent :sick: please help me

ur kaif

Check whether you’re using MySQL 5.5 and post in the appropriate forum also, this has nothing to do with php kaif.

well if MySQL ran the SELECT query every 5 seconds how is the data supposed to get into PHP? It won’t initiate a request to the web server.

I think a cron job might be more useful.

iam using 5.1.4,

iam actually asking, does the select query should work in event ??

if it is not working ,than how to write the query that should display all the records form the table in every 1 hour

i don’t know, Please tell me how to select the table columns on every 1 hour on my page

please help me friend

If you have cPanel go to advanced > cron jobs and set one to run every hour. The command will usually look like:


php -q /home/your_user_name/my_path/my_script.php

In that PHP file you can then connect to your DB, query it, and do something with the data.

thanks for your response, but i want code which automatically generate the select query from backend (my SQL) .
please give me the code
MAAZ

thanks to your response, but i cant find the option advance in control panel in windows xp

hi mazz, you’re making no sense.
please show me the code
ANTHONY

thanks to your response, but i cant find the option advance in control panel in windows xp
please help me friend

This is kaif khan

Misunderstanding there… :rolleyes:
cranial-bore is pointing to your hosting cpanel account not your OS control panel.
Ok, that means you are testing all these on your local pc?
One thing i don’t understand is you said, you wana display the results, am i right? display results where?, browser?

Please be more clear with your questions.

EDIT: What is this, maaz, kaif???, both are same, threads are merged?.

Thanks to your response
we both are working on same problem,we are using on browser.

my problem is that , i want to display the employee details form the table(that is form mysql) for every 1 hour.without giving the command .that is at the backend that query run at every 1 hour and display at every 1 hour

MySQL events (or temporal triggers) are triggers that are executed by MySQL at predefined intervals.
MySQL cannot PUSH the information to your browser unless browser explicitly asks for it.
To put it more simple, unless you tell your browser “hey, refresh this URL every 1 hour”, MySQL will not give you the information.
That’s why Cron job was suggested, so you can execute a php script every 1 hour and then you can do whatever you want with the data.
The control panel in question wasn’t Windows one, it was the cPanel - an administration web script / interface. The fact you glanced trough people’s responses means you aren’t even reading or bothering to read.

It does not matter if you created the event or not, you are approaching the problem from absolutely wrong angle.
What surprises me how you even got to work with the technology whose basics you don’t understand and how mr. Anthony is calm enough to help you guys out when this should be charged for.

If you’re doing this “feature” for a client and if you have no idea what you’re supposed to do - at least hire someone who does instead of charging someone for stuff you got no clue about.

I’m sorry for sounding rude, but I find it extremely bad when someone asks for help for free about semi-advanced things that they sell to other people, especially when they cannot be bothered to at least google the stuff out or learn the terminology or even the basics about the technology.