An If statement within an If statement
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
精彩评论