bgbs Posted November 4, 2009 Share Posted November 4, 2009 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; } }?> Quote Link to comment https://forums.phpfreaks.com/topic/180288-solved-help-to-add-else-echo-statement/ Share on other sites More sharing options...
Garethp Posted November 4, 2009 Share Posted November 4, 2009 Just add else {echo "FREE MEMBER";} at the end of those else ifs Quote Link to comment https://forums.phpfreaks.com/topic/180288-solved-help-to-add-else-echo-statement/#findComment-951042 Share on other sites More sharing options...
Adam Posted November 4, 2009 Share Posted November 4, 2009 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. Quote Link to comment https://forums.phpfreaks.com/topic/180288-solved-help-to-add-else-echo-statement/#findComment-951050 Share on other sites More sharing options...
bgbs Posted November 4, 2009 Author Share Posted November 4, 2009 nice. that was easy Thanks guys for your help TOPIC SOLVED Quote Link to comment https://forums.phpfreaks.com/topic/180288-solved-help-to-add-else-echo-statement/#findComment-951066 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.