Jump to content

Expire base on time


depojones

Recommended Posts

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


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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.