Jump to content

Recommended Posts

To the php statement below I would like to add one more option that if it does not meet any of the required member statuses that it would simply read FREE MEMBER. Is it possible to add that statement if we dont have mem_type_id set for free member in the database?

   

 

 

 

 

 <?PHP 
		if($admin=="yes")
		{
			$cur_mem = $db->get_row("SELECT * FROM mem WHERE user_id = '$v_id'");

			if($cur_mem->mem_type_id == 2)
				echo "<strong><span style=\"color: red; \">LIFETIME MEMBER</span></strong>";
			elseif($cur_mem->mem_type_id == 3)
				echo "       <strong><span style=\"color: red; \">6 MONTH MEMBER</span></strong>";
			elseif($cur_mem->mem_type_id == 4)
				echo "<strong><span style=\"color: red; \">ANNUAL MEMBER</span></strong>";
			elseif($cur_mem->mem_type_id == 6)
				echo "<strong><span style=\"color: red; \">MONTHLY MEMBER</span></strong>";
			elseif($cur_mem->mem_type_id == 7)
			 echo "<strong><span style=\"color: red; \">QUARTERLY MEMBER</span></strong>";
			elseif($cur_mem->mem_type_id == 10) {
				echo "<strong><span style=\"color: red; \">EXPIRED MEMBER</span></strong>";
					if($cur_mem->renew_refused == "Yes")
						echo "<br /><span style=\"color:red\">Renewal refused</span> ".$cur_mem->refused_date;
			}	
		}?>

Link to comment
https://forums.phpfreaks.com/topic/180288-solved-help-to-add-else-echo-statement/
Share on other sites

Could make this much cleaner using a switch:

 

            switch ($cur_mem->mem_type_id)
            {
                case 2:
                    echo "<strong><span style=\"color: red; \">LIFETIME MEMBER</span></strong>";
                    break;
                case 3:
                    echo "       <strong><span style=\"color: red; \">6 MONTH MEMBER</span></strong>";
                    break;
                case 4:
                    echo "<strong><span style=\"color: red; \">ANNUAL MEMBER</span></strong>";
                    break;
                case 6:
                    echo "<strong><span style=\"color: red; \">MONTHLY MEMBER</span></strong>";
                    break;
                case 7:
                    echo "<strong><span style=\"color: red; \">QUARTERLY MEMBER</span></strong>";
                    break;
                case 10:
                    echo "<strong><span style=\"color: red; \">EXPIRED MEMBER</span></strong>";
                    if($cur_mem->renew_refused == "Yes")
                        echo "<br /><span style=\"color:red\">Renewal refused</span> ".$cur_mem->refused_date;
                    break;
                default:
                    echo "<strong><span style=\"color: red; \">FREE MEMBER</span></strong>";
            }

 

You could even tidy it up further placing the "<strong><span...." stuff before and after the switch removing the repetition.

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.