user2958359
user2958359

Reputation: 131

Triggering in php mySql

Let I have a table as the following...

-----------------------------
| id    |  questions  | type |
------------------------------

Based on server time I want to pick 5 random rows from this table and place those into another table.And I want this to happen after every 15 minutes of the server time. I am using php mySql. How this can be done. Is there any way so that it will run in localhost (I am using windows) and linux server. If anybody of you have the idea please help me. Thanx

Upvotes: 0

Views: 182

Answers (2)

janenz00
janenz00

Reputation: 3310

You need a scheduler. You can write a PHP script to program your requirement. Since you are running Windows, start your Windows Task Scheduler, add your script as the action.

If you were running Linux, you would be doing what @Vit Kos noted above.

Upvotes: 0

Vit Kos
Vit Kos

Reputation: 5755

Assuming you have linux server and cronjob installed:

STEP 1: Open a Terminal Window

Once you have opened a terminal window, type in the following...

crontab -e

STEP 2: Add a cron job

At the end of the file paste one of the following to have your cron job run...

Every Minute:

* * * * * /path/to/php -f /absolute/path/to/script.php 

Every Five Minutes:

*/5 * * * * /path/to/php -f /absolute/path/to/script.php 

Every Hour:

0 * * * * /path/to/php -f /absolute/path/to/script.php 

Every Five Hours:

0 */5 * * * /path/to/php -f /absolute/path/to/script.php 

STEP 3: Save

And in your php file you can do those manipulations you stated as you wish

Upvotes: 3

Related Questions