Reputation: 13
I've an if else statement.
IF the recordset is not empty AND if a specific record is greater then 0 then show.....
<?php if ($totalRows_bigimgRec > 0) { ?>
<?php
if(( $row_bigimgRec['disable_big_image'] ) > (0)) {
?>
The above is the code I have. Yes it came from dreamweaver, but I want to have it as one statement.
I have tried hundreds of different ways to no avail.
<?php if ($totalRows_bigimgRec > 0) {
AND
if(( $row_bigimgRec['disable_big_image'] ) > (0)) {
?>
the 2 conditions have to be met before I can show some thing other further down my page.
Can anyone advise as to how to get this working, I have read many manuals but am new to php and cannot get my head around.
Upvotes: 0
Views: 55
Reputation: 1010
You can use &&
where IF Statement can check both conditions are TRUE
<?php
if (!empty($totalRows_bigimgRec) && $row_bigimgRec['disable_big_image'] > 0){
// rest of your code
}
?>
I saw some extra parenthesis as well which PHP will warning with syntax error. Remove then too.
Hope it helps you.
Upvotes: 1
Reputation: 21
As you can see at http://php.net/manual/en/language.operators.logical.php
You should $c = ($a and $b);
So within your IF-statement you want both to be TRUE, hence:
<?php if( ($totalRows_bigimgRec > 0) and ($row_bigimgRec['disable_big_image'] > 0 )) {
//code to be run when the condition is met
} ?>
Alternatively you can use && instead of AND
Upvotes: 1
Reputation: 416
You should use something like:
<?php if(!empty($whatever) && $othervariable > 0){ ?>write html <?php } ?>
Upvotes: 0
Reputation: 4880
something like this..
if ($totalRows_bigimgRec > 0 && $row_bigimgRec['disable_big_image'] > 0) {
// do something
}
Upvotes: 1