Jump to content

Conditional display of images depending on subscriber status


driftwood11

Recommended Posts

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 like

If member = paid display all photos
If member !=  paid but property is older than 3 months, display photo
Else != paid and property is < 3 months, don't display photo

Any help appreciated.
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.
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]


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.