View Full Version : PHP date change script that calls a database
neiro
October 4th, 2004, 01:20 PM
Hello,
I need to create a php script that whenever the date changes it calls the database for that days content.
Does anyone know where I can find a script to do this?
Thanks,
chad
Yeldarb
October 4th, 2004, 05:29 PM
Have a field in the database that has what date it is for, and then do
mysql_query("SELECT * FROM TABLE WHERE date=$yourDate");
λ
October 4th, 2004, 05:50 PM
You'd need to use a cronjob on Unix to do that :) Google it.
teiz77
October 5th, 2004, 08:18 AM
You'd need to use a cronjob on Unix to do that :) Google it.
No, you don't! you can get the results as they are requested. You could also get today's events with: mysql_query("SELECT * FROM TABLE WHERE date=CURDATE()"); date must be a timestamp or something simular.
CyanBlue
October 5th, 2004, 12:24 PM
What njs12345 is saying is that you will need the crontab if you wish to update it regularily like everyday 12:01AM or every three hours or something like that... :)
(crontab works only in the Linux/Unix host... Similar thing can be found in the Windows based host as well... Some schedule or something similar it is called...)
teiz77
October 6th, 2004, 03:56 AM
yeah, I know where the cron jobs are for (I have a RedHat server). But on a shared host you rarely have access to the crontab. You should build a trigger in your php script that checks if there is a job to be done everytime the script is called. No one will need to see the data when the script is not requested, so you can update it on request. This way it will always work.
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.