jwk811 Posted February 22, 2010 Share Posted February 22, 2010 $sql = "UPDATE message SET status = 'new' WHERE post_time < (x)"; i want it to change the status to 'new' for every message that was posted less than 30 minutes ago Quote Link to comment Share on other sites More sharing options...
schilly Posted February 22, 2010 Share Posted February 22, 2010 what's the data type of post_time in that table? Quote Link to comment Share on other sites More sharing options...
jwk811 Posted February 22, 2010 Author Share Posted February 22, 2010 datetime Quote Link to comment Share on other sites More sharing options...
schilly Posted February 22, 2010 Share Posted February 22, 2010 try this $sql = "UPDATE message SET status = 'new' WHERE post_time >= FROM_UNIXTIME(" . time() - 60*30 . ") "; there should be a way directly in mysql but i'm not totally sure on the syntax. you can look at the date/time f'ns in mysql here: http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html Quote Link to comment Share on other sites More sharing options...
jwk811 Posted February 22, 2010 Author Share Posted February 22, 2010 uh didnt work. still all old Quote Link to comment Share on other sites More sharing options...
schilly Posted February 22, 2010 Share Posted February 22, 2010 This should work too $sql = "UPDATE message SET status = 'new' WHERE post_time >= DATE_SUB(NOW(), INTERVAL 30 MINUTE) "; Did you try a select to see if it matched any rows? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.