date- How to change column's value without user interaction
Posted: Mon Mar 19, 2007 4:09 pm
How can you change this "expire" to change from 0 to 1 when the required date is already gone? The only way I could think of is to check the database, get the request whose required_by_date > todays date where todays date is a php variable that stores today's date. But it means I have to check that every time the user visit the page. Isn't there a better way to set expire to 1 when the date is gone?
I am using this select statement to show the requests that have been approved and have not expired yet.
table :
I am using this select statement to show the requests that have been approved and have not expired yet.
Code: Select all
$query= 'SELECT id,quote_no,username,title,description,post_date,required_by_date FROM request Where approve= 1 && expire=0 ORDER BY quote_no DESC';
table :
Code: Select all
CREATE TABLE `request` (
`id` int(11) NOT NULL auto_increment,
`quote_no` varchar(40) NOT NULL default '',
`username` varchar(50) default NULL,
`city` varchar(255) NOT NULL default '',
`title` varchar(255) NOT NULL default '',
`description` varchar(255) NOT NULL default '',
`post_date` date NOT NULL default '0000-00-00',
`required_by_date` date NOT NULL default '0000-00-00',
`approve` int(11) NOT NULL default '0',
`expire` int(11) NOT NULL default '0',
PRIMARY KEY (`id`)
) ;