bruckerrlb Posted October 8, 2009 Share Posted October 8, 2009 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 More sharing options...
Bricktop Posted October 8, 2009 Share Posted October 8, 2009 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. Link to comment https://forums.phpfreaks.com/topic/176968-else-if-statement-and-operators/#findComment-933082 Share on other sites More sharing options...
bruckerrlb Posted October 8, 2009 Author Share Posted October 8, 2009 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 Link to comment https://forums.phpfreaks.com/topic/176968-else-if-statement-and-operators/#findComment-933161 Share on other sites More sharing options...
mrMarcus Posted October 8, 2009 Share Posted October 8, 2009 why wouldn't this work? (($field[type] == "textarea") && ($field[customfieldid] != '53')) and yes, you can nest if statements within elseif statements .. you just need to try these things to find out. seriously, just try things. Link to comment https://forums.phpfreaks.com/topic/176968-else-if-statement-and-operators/#findComment-933164 Share on other sites More sharing options...
bruckerrlb Posted October 9, 2009 Author Share Posted October 9, 2009 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 Link to comment https://forums.phpfreaks.com/topic/176968-else-if-statement-and-operators/#findComment-933889 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.