Forum Moderators: coopster

Message Too Old, No Replies

lots of IF Statements for building a page

         

jackdack

10:57 am on May 8, 2006 (gmt 0)

10+ Year Member



I'm using if/then statements to build a good portion of my page(s). I actually want to use IF statemetns for the navigation menu i.e. if $cat1 then display cat1 menu links, if $cat2 then dispaly cat2 menu links etc.
I don't know much PHP, is there anything wrong conceptually with what i'm describing? is there any limit to how many IF Statements can go on a page? I think technically it will work I just wonder if I'm creating a problem using so many IF statements...
Thanks

jackdack

11:05 am on May 8, 2006 (gmt 0)

10+ Year Member



I should have said lots of SWITCH statements...
thanks

eelixduppy

11:20 am on May 8, 2006 (gmt 0)



Hello

I don't see anything wrong with using a lot of if statements in your code, but, you should try to find an alternative way of doing something before you go crazy. This depends, however, on what you are trying to accomlish. An example of this would be creating a decoder. Instead of doing an if statement for each possible character conversion, you can use arrays to your advantage.

Good luck!

eelix

jackdack

10:16 pm on May 8, 2006 (gmt 0)

10+ Year Member



nothing too complex, just switching content in/out depending on page variables. i don't know much php so right now my options are limited, i was just checking I wasn't creating a problem but it sounds like it's OK, thanks

mcavic

10:53 pm on May 8, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Technically, there's no limit, but it'll quickly get hard to manage.

jackdack

2:14 am on May 9, 2006 (gmt 0)

10+ Year Member



thanks mcavic