...

View Full Version : Regarding scheduling jobs in php



Rajesh77
06-18-2010, 06:28 AM
Hi Everyone,

I have an issue regarding the scheduling of jobs in php.
My requirement is i have add_details table in my phpmyadmin database . In that table i have both buyers and sellers who would post their advertisements for every category (like computers , electronics etc) .
When a buyer posts his add for a certain category in the website then i want to run a job in php at night 12:00 o'clock for getting the data of sellers for that category .
So how to run a job in php and get the data from the table present in
phpmyadmin database ? .
How to write the code for scheduling this job in php .?
And should i host the site in internet for scheduling job in php? can i schedule a job in php from my local system .

Please help me .. awaiting for your response .

Thank u very in advance.

shanu.chaudhary
06-18-2010, 06:50 AM
You can do this in 2 ways.

1) By using cron job setting in control panel for the script (PHP Script) to run for getting for getting the data of sellers for that category.

2) By setting the task in your PC (scheduled tasks - but I dont think this works)

Rajesh77
06-18-2010, 08:07 AM
Hi Shanu ,

U said it can be done by cron job setting in control panel of the script.
I didn't get where will be the control panel for the script.i am using xammp as the webserver in my local machine .
Can u please explain where would be the control panel present..?

And i heard that cron job is for unix operating system , can we run the job it in windows also ...

Thanx ,
Rajesh.

shanu.chaudhary
06-18-2010, 08:15 AM
Hi Shanu ,

U said it can be done by cron job setting in control panel of the script.
I didn't get where will be the control panel for the script.i am using xammp as the webserver in my local machine .
Can u please explain where would be the control panel present..?

And i heard that cron job is for unix operating system , can we run the job it in windows also ...

Thanx ,
Rajesh.

Its not control panel of the script, I said to set the cron job for the script.

I hope your site is live or it will be live sometime?? It is web based application right?

You can set the cron job once your site is live.

Rajesh77
06-18-2010, 09:54 AM
yes its web application ..
It is not live now.. Can't i schedule the job when its is not online ..
Can u tell me how to right the code for scheduling the php script..

Thanx,
Rajesh.

shanu.chaudhary
06-18-2010, 10:06 AM
Yes, You cannot schedule the job when it is not online using cron job. CRON JOB is set in the control panel by giving the path to the script you write as per your requirements.

Suppose, you want to get the data of sellers for that category "a"

You will create a php file as usual with the script in it



$query = mysql_query ("Select sellers from table_sellers where category_name ='a'");
$res = mysql_fetch_array($query);
// you wil get the results here
$sellers = $res["sellers"];


and this $ sellers variable is the output of your script, store it as per your requirement, say write into a txt file from where you can see the data for sellers daily.

If you want to run the job before making it live just create the php file and then use the windows scheduler to run the script on your local pc

Hope this helps.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum