Page 1 of 1

If statement in another if statement

Posted: Wed May 24, 2006 1:09 pm
by Milan
I have this :

Code: Select all

<? if ($_GET['cat']=="all"){
require_once('Connections/allcat.php');
}
else
require_once('Connections/singlecat.php');
?>

that code will check if user wants to view all categories or a single product category BUT now i have another problem i need also to check if record count is 0 and in that case just echo "recordset is empty". so what is the correct way yo implement that second if?

Code: Select all

if ($totalRows_product=="0") {....
or there is another way to solve the problem



thanks

Posted: Wed May 24, 2006 1:20 pm
by Flamie
not sure I understand it right but would that work for you?

Code: Select all

if($recordcount == 0)
{
}
elseif($_GET['cat']=="all")
{
}
else
{
}

Re: If statement in another if statement

Posted: Wed May 24, 2006 1:21 pm
by Christopher

Code: Select all

<?php
if ($totalRows_product > 0) {
    if ($_GET['cat']=="all"){
        require_once('Connections/allcat.php');
    } else {
        require_once('Connections/singlecat.php');
    }
} else {
    require_once('Connections/norecords.php');
}
?>
Or:

Code: Select all

<?php
if ($_GET['cat']=="all"){
    if ($totalRows_product > 0) {
        require_once('Connections/allcat.php');
    } else {
        require_once('Connections/norecords.php');
    }
} else {
    require_once('Connections/singlecat.php');
}
?>

thanks!

Posted: Wed May 24, 2006 1:29 pm
by Milan
works great for cat=all but it does not check if single category is empty or not ( my bad i should have mentinoned that i have another reecordset also for single categories)

other one ( single cat)

$totalRows_singleproject


thanks guys!

Re: If statement in another if statement

Posted: Wed May 24, 2006 1:32 pm
by PrObLeM

Code: Select all

<? 
	if ($_GET['cat']=="all"){
		if( $totalRows_product ) {
			require_once('Connections/allcat.php');
		} else {
			//all cat empty
		}
	} else {
		if( $totalRows_singleproject ) {
			require_once('Connections/singlecat.php');
		} else {
			//single cat empty
		}
	}
?>

Posted: Wed May 24, 2006 1:42 pm
by Milan
GREAT !!!!

In my code i was missing a }

YOU GUYS ROCK!