Jump to content

else if statement and operators


bruckerrlb

Recommended Posts

I have an else if statement here, and I need for it to always execute, but I'm trying to stop a field in the database from showing up, for example the following is my code:

 

 

<{elseif $field[type] == "textarea"}>
		  <tr>
			<td width="30%" align="left" valign="top" class="row2"><span class="<{if $posterror == true && $field[isrequired] == 1 && $field[value] == ""}>redtext<{else}>smalltext<{/if}>"><b><{$field[title]}>:<{if $field[isrequired] == "1"}><span class="redtext"> *</span><{/if}></b><br/><{$field[description]}> </span></td>
			<td width="70%"><textarea name="<{$field[name]}>" cols="50" rows="5" class="swifttextarea"><{$field[value]}></textarea></td>
		  </tr>

 

I'd like to set a condition where this still gets spit out if it's a text area, but won't spit out the record when $field[customfieldid] is equal to 53

 

Can anyone offer any insights to this?

 

 

Link to comment
https://forums.phpfreaks.com/topic/176968-else-if-statement-and-operators/
Share on other sites

Hi bruckerllb,

 

Try adding an AND condition to the else statement, something like:

 

<{elseif $field[type] == "textarea" && !$field[customfieldid]=='53'}>
		  <tr>
			<td width="30%" align="left" valign="top" class="row2"><span class="<{if $posterror == true && $field[isrequired] == 1 && $field[value] == ""}>redtext<{else}>smalltext<{/if}>"><b><{$field[title]}>:<{if $field[isrequired] == "1"}><span class="redtext"> *</span><{/if}></b><br/><{$field[description]}> </span></td>
			<td width="70%"><textarea name="<{$field[name]}>" cols="50" rows="5" class="swifttextarea"><{$field[value]}></textarea></td>
		  </tr>

 

So with the above it should always output as long as the $field[type] is a textarea AND the $field[customfieldid] is not 53.

 

Hope this helps.

hi Bricktop,

 

I appreciate the help, I was thinking about that before, and tried it with your advice, but it didn't seem to work. I think the reason is because the output in this else if statement is solely relying on what the $field[type] will be, so I need to figure out a way to put an if statement inside an elseif statement if that's even possible. Any ideas?

 

Thanks again

hey MrMarcus, I agree with you 100% on trying things out. The reason why I'm fine combing so much is because this project is already live and a ton of people rely on it to work properly. I only have about 90% of the original source code (the rest is encrypted) so I can't get it fully working on the server I have here on my computer.

 

I"m not sure why

(($field[type] == "textarea") && ($field[customfieldid] != '53'))

isn't working, I've also tried the following

<{elseif (($field[type] == "textarea") && ($field[name] != "the name")) }>
<{elseif (($field[type] == "textarea") && ($field[title] != "the title")) }>

 

but every time, this one record in the db keeps making it through, I appreciate the suggestions thus far, and any others would be greatly appreciated

 

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.