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

PHP, double-if statement (?)

Options
  • 19-06-2006 12:54am
    #1
    Registered Users 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 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 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