driftwood11 Posted January 5, 2007 Share Posted January 5, 2007 I have a membership-based property site. Unpaid members can try out the site but not view images of properties on a summary page. Paid members can see all the images and then click on the image for further info.I want to now display photos to EVERYONE provided the property has been on my database for longer than 3 months. I have a MYSQL field including a date when it was added and I obviously have a check on each page as to the viewer's payment status. The bit I'm stuck on is how to write the if else statement.In English I want to say something likeIf member = paid display all photosIf member != paid but property is older than 3 months, display photoElse != paid and property is < 3 months, don't display photoAny help appreciated. Quote Link to comment https://forums.phpfreaks.com/topic/33006-conditional-display-of-images-depending-on-subscriber-status/ Share on other sites More sharing options...
Jessica Posted January 5, 2007 Share Posted January 5, 2007 you pretty much wrote it right there. What are you asking for? The sql?what type is the field? DATE, DATETIME, or INTEGER (storing timestamp)?if the first two, use php's date() function to format the date into this string: "Y-m-d" or "Y-m-d H:i:s"If it's integer, use time()then add three months to the date. Quote Link to comment https://forums.phpfreaks.com/topic/33006-conditional-display-of-images-depending-on-subscriber-status/#findComment-153670 Share on other sites More sharing options...
.josh Posted January 5, 2007 Share Posted January 5, 2007 The most efficient way I can think of is (assuming that the user whether paid or unpaid has to login) to find out whether the user is paid or unpaid when they first login. I assume that there is some kind of column with a paid/unpaid flag of some kind. Get that info when the user logs in, so that you can do something like this:pseudo code:[code]$sql = "select * from properties ";$sql .= ($user['paymentstatus'] == 'unpaid') ? "where {propertydate > 3 months}" : "";$result = mysql_query($sql);[/code] Quote Link to comment https://forums.phpfreaks.com/topic/33006-conditional-display-of-images-depending-on-subscriber-status/#findComment-153673 Share on other sites More sharing options...
ikmyer Posted January 5, 2007 Share Posted January 5, 2007 store the date the pic was added in unix time stamp and then compare it to...$3monthago = mktime(0, 0, 0, date("m")-3, date("d"), date("Y")); Quote Link to comment https://forums.phpfreaks.com/topic/33006-conditional-display-of-images-depending-on-subscriber-status/#findComment-153674 Share on other sites More sharing options...
driftwood11 Posted January 5, 2007 Author Share Posted January 5, 2007 Thanks - I'll have a go at some of your ideas. Quote Link to comment https://forums.phpfreaks.com/topic/33006-conditional-display-of-images-depending-on-subscriber-status/#findComment-153699 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.