Advice on Calculating Attendance within dates needed

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

simonmlewis
DevNet Master
Posts: 4435
Joined: Wed Oct 08, 2008 3:39 pm
Location: United Kingdom
Contact:

Re: Advice on Calculating Attendance within dates needed

Post by simonmlewis »

The membership is for a year.
So they attend the eligible amount of events, and then before a "member" for a year from that date.
Once that date expires, I need to base the "new year" to check if they have done (all we did earlier)....

At the moment it's based on either their Join date, or their Membership date. But if the membership expires.. I'm not sure on what date to based it on....Sorry this isn't making much sense..

Code: Select all

 $querydiary = "SELECT * FROM diary WHERE memberid =:memberid AND dateattended >= '$datestart' ORDER BY dateattended ASC";
This is the problem bit. I need to base it on $datestart.
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
simonmlewis
DevNet Master
Posts: 4435
Joined: Wed Oct 08, 2008 3:39 pm
Location: United Kingdom
Contact:

Re: Advice on Calculating Attendance within dates needed

Post by simonmlewis »

Maybe I could run this at the top.

Code: Select all

$datestart = NULL;
if ($row->datemembership == NULL) { $datestart = $row->datejoined;}
else { 
$dateexpire = date('Y-m-d', strtotime("+12 months", strtotime($row->datemembership)));
$todaydate = date('Y-m-d');
if ($dateexpire > $todaydate) 
  { 
  $datestart = $row->datemembership;
  }
else
  {
  $datestart = $dateexpire;
  }
}
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: Advice on Calculating Attendance within dates needed

Post by Celauran »

simonmlewis wrote:Once that date expires, I need to base the "new year" to check if they have done (all we did earlier)....
Base it on what? The last year? The year during which their membership was active?
simonmlewis
DevNet Master
Posts: 4435
Joined: Wed Oct 08, 2008 3:39 pm
Location: United Kingdom
Contact:

Re: Advice on Calculating Attendance within dates needed

Post by simonmlewis »

I've just realised there is a bit of a hitch here. Not sure if it's a bad hitch. But if someone joins the club, then plays as described before.... they get the membership thing for a year.
But when that year lapses, I guess that membership expires. And there will be a period during which they are no longer a discounted member, until they attend again to renew.

My idea above would work. If the expire date is less than the todaydate, then they are expired and the discount stops.
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
Post Reply