depojones Posted February 25, 2009 Share Posted February 25, 2009 Hi folks, I am working on a real estate web portal that will require users to either sign up and list and manage their properties or search for available houses based on the different criteria,using php and mysql. Based upon request of the client i am suppose to develop the property listing application with a date & time based expiration function or class.That will automatically expire and deactivate a users property after a specified period of time for example 7 days or 30 days. From my own understanding of php coding i've attempted to solve the problem by creating 3 extra fields in the property listing table in my mysql database. the first field will be a ENUM field for listing status that will have default value (Yes,No )or (1,0) while the 2nd extra field is a timestamp field that automatically stores the time property was listed while the 3rd field is also timestamp that calculates and stores the specified expire date of the listing.(I guess or presume that should be expected too) Now i actually need anyone who's worked on a similar app before to please guide me through the steps to write the function or script so that i can actually use the script to calculate and arrive at the date and time due and automatically run via a CRON or whatever and automatically deactivate the listing by updating the active field from 1 to 0 or Yes to No Link to comment https://forums.phpfreaks.com/topic/146947-expire-base-on-time/ Share on other sites More sharing options...
samshel Posted February 25, 2009 Share Posted February 25, 2009 1) Write cron 2) Select all active records from table 3) check 3rd field if the time has already passed. if yes deactivate the listing by updating record. Link to comment https://forums.phpfreaks.com/topic/146947-expire-base-on-time/#findComment-771448 Share on other sites More sharing options...
depojones Posted February 25, 2009 Author Share Posted February 25, 2009 Can you give me a head start to that. In terms of the actual code??? Link to comment https://forums.phpfreaks.com/topic/146947-expire-base-on-time/#findComment-771454 Share on other sites More sharing options...
samshel Posted February 26, 2009 Share Posted February 26, 2009 mysql_connect("localhost", "user" ,"***"); mysql_select_db("dbname"); $strSql = "UPDATE propertylisting set propertylisting_status = 'NO' WHERE propertylisting_status = 'YES' AND propertylisting_expiry < '".time()."'"; mysql_query($strSql); //Assumptions //- u will be showing records with status = 'YES' //- u r storing unix time stamp in your third field whcih is _expiry, //- u will run this script periodically, Link to comment https://forums.phpfreaks.com/topic/146947-expire-base-on-time/#findComment-771469 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.