Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

PHP, double-if statement (?)

  • 19-06-2006 12:54AM
    #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