Jump to content

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]


This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.