Webmastersite.net
Register Log In

custom function calls

Title custom function calls
Description I'm a posting fool today
Message Text I went over the manual and got a fair understanding of how you can create functions in the different classes that can then be called in your templates. Here's my dilemma: I have a birth_date field in my integrated database in unix format ('0000-00-00'). I would like to display the user age on the view_profile. I tried to use this function: function calculateage() { $amember = new member('id', 'birth_date', $id); $cur_year=date("Y"); $cur_month=date("m"); $cur_day=date("d"); $dob_year=substr($birth_date, 0, 4); $dob_month=substr($birth_date, 5, 2); $dob_day=substr($birth_date, 8, 2); if($cur_month>$dob_month || ($dob_month==$cur_month && $cur_day>$dob_day) ) return $cur_year-$dob_year-1; else return $cur_year-$dob_year; } This is not working (though I've been able to get it to display various wrong data when tweaking). The main issue is I do not understand how to call a member's 'birth_date' field into the function (using the appropriate sql). I assigned{MEMBERBIRTH_DATE} into the view profile and the '0000-00-00' value was displayed as expected. Can you elaborate on how I can call these values into a custom function that I could then use. Thanks! Thanks
Rating
  • 0/5
  • 1
  • 2
  • 3
  • 4
  • 5
0/5 based on 0 votes.
Ownership knotworking
Views 456 views. Averaging 0 views per day.
Similar Topics
Submission Date May 02, 2005 - 10:31 PM