Jump to content


Photo

PHP Language Help!


  • Please log in to reply
2 replies to this topic

#1 Atlanticas

Atlanticas
  • Members
  • PipPip
  • Member
  • 11 posts

Posted 15 March 2006 - 03:58 AM

Basically this coding adds a color desgination for each of my registered users based on how long they have joined. Example: Mike joins on 3/1/06 and is considered Orange during his first 90 days of joining, then turns Blue, etc.

However I want to do the opposite. Instead I want the code to determine the color based on how much membership time is left. For example within the last 90 days of membership, I would like it to put someone as Orange. I hope I am making sense, I had someone do the code for me however he is on vacation and wont be back for a month. Thanks.

[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]function get_status_color($member_id)
{
$_db = new mysql_db;
$now=strtotime("now");
$_db->query("SELECT exp_date, join_date FROM member WHERE member_id='".$member_id."'");
$_db->move_next();
$exp_date=$_db->f('join_date');
$sec_left=$now - $exp_date;

if($sec_left <= 0)
{
return 'WHITE';
}

$days_left=$sec_left / 86400;


//echo $days_left;

if($days_left <= 90 )
{
$color='ORANGE;
}
elseif($days_left <= 180 )
{
$color='BLUE';
}
elseif($days_left <= 851 )
{
$color='PURPLE';
}

if($days_left > 851 )
{
$color='PURPLE';
}


return $color;
}




?>[/quote]

#2 wickning1

wickning1
  • Members
  • PipPipPip
  • Advanced Member
  • 405 posts

Posted 15 March 2006 - 07:54 AM

Just change two lines:

$exp_date=$_db->f('exp_date');
$sec_left=$exp_date - $now;

#3 Atlanticas

Atlanticas
  • Members
  • PipPip
  • Member
  • 11 posts

Posted 15 March 2006 - 09:52 AM

Wow, thank you so much! I spent many hours on this and never would have guessed. Thank you, I am very appreciative and can't say thanks enough!!!! :)




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users