开发者

An If statement within an If statement

开发者 https://www.devze.com 2023-04-08 09:53 出处:网络
I\'m checking to see if a check box has been checked on a search form. If that box has been checked, the value it outputs will be \"No\".

I'm checking to see if a check box has been checked on a search form. If that box has been checked, the value it outputs will be "No".

So if the value is "No", then I want to use an If statement to echo some PHP. The problem is, the PHP that I want to echo is an actual If statement itself.

Here's my code right now:

$showoutofstock = $_SESSION['showoutofstock']; 
if ( $showoutofstock == "No" ) {
} 
if($_product-开发者_JS百科>isSaleable()): {
}


You can't really "echo some PHP". PHP is processed on the server-side, and the result is usually HTML that the browser client reads and displays.

It's not clear what you're actually trying to accomplish. Can you clarify a bit?

This might help though -- it's simply showing how to nest if statements, which may be all that you're asking for:

<?php
$showoutofstock = $_SESSION['showoutofstock']; 
if ( $showoutofstock == "No" ) {
    if($_product->isSaleable()) {
    }
} 
?>


you are closing your if before writing another if inside it

<?php
    $showoutofstock = $_SESSION['showoutofstock']; 
    if ( $showoutofstock == "No" ) { //main if clause start
        if($_product->isSaleable()) {//if clause inside main if start
        } //inner if clause ends here
    }//outer if clause ends here
?>

try it like this and yes you can check for the value of check box and can code accordingly inside that if clause

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号