Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

PHP, double-if statement (?)

  • 18-06-2006 11:54pm
    #1
    Registered Users, Registered Users 2 Posts: 8,488 ✭✭✭


    Never sure to post PHP questions here or in the Web/Flash forum.. I'll try here for a change.

    Here's the code I've got :
    	foreach ($channels as $channel) {
    		if ($channel["Category"] == $cat){
    			if ( ! isset($channel["NotPublic"]) || ! $channel["NotPublic"] || valid_user() ) {
    				$out[] = theme_guide_summary_wrapper($channel, theme_guide_summary($channel, $files, 4), $files);
    			} // if
    		} // if
    	} // foreach
    

    What I want is for the first IF statement ($channel["Category"] == $cat) to only be called if $_GET is set.

    Something like this ugly piece of code :
    	foreach ($channels as $channel) {
    	if (isset($_GET["cat"])) {
    		if ($channel["Category"] == $cat){
    	}
    			if ( ! isset($channel["NotPublic"]) || ! $channel["NotPublic"] || valid_user() ) {
    				$out[] = theme_guide_summary_wrapper($channel, theme_guide_summary($channel, $files, 4), $files);
    			} // if
    	if (isset($_GET["cat"])) {
    		} //if
    	}
    	} // foreach
    

    But that doesn't work, obviously.

    Any help would be great,
    cheers.


Comments

  • Registered Users, Registered Users 2 Posts: 304 ✭✭PhantomBeaker


    It's an easy enough problem, so I'll just give a coupla hints.

    Look at line 4 of your second block of code (the one where you only want the other ifs to happen if the first if is true):

    Is that closing brace what you want? Are the others as nested as you think?

    Think on those bits, and you'll find your answer.

    Aoife - who's not giving the answer straight off due to a personal motto of "You never really know how something works until you break it".


  • Registered Users, Registered Users 2 Posts: 8,488 ✭✭✭Goodshape


    Yeap, that would be an easy one then.

    Cheers :D

    (don't believe how stupid that second block of code was... ffs! :) )


Advertisement