I have the below javascript function:
 function pageRedirect() {
     window.location.replace("ProdTypes.php");
 }
 setTimeout("pageRedirect()", 3000);
in a PHP if else statement (see below):
if($ptRowCount > 0) :
            if ($ptQTYRowCount > 0):
                $errors[]='Cannot delete or Archive product which has a Product Quantity > 0!!! Refreshing Page in 3 seconds...';
                ?>
                <script>
                    pageRedirect();
               </script>
                <?php 
                elseif($ptQTYRowCount == 0):
                $sql = "UPDATE producttype SET ProdTypeArchive='1' WHERE ProductTypeID = '$delete_id'";
                $_SESSION['success_flash']='Product Type was Archived succesfully';
            endif;
        else:
             $sql = "DELETE FROM producttype WHERE ProductTypeID = '$delete_id'";
             $_SESSION['success_flash']='Product Type was deleted succesfully';
        endif;
I require that the javascript counter only comes into action in the if statement where if ($ptQTYRowCount > 0):
At the moment it is realoading the page even when the if statement is not triggerred.
Anyone can help please?
P.S. I do not want to use Header for redirection. WHen I use headers I have the below error:
Warning: Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\aresV2\admin\includes\navigation.php:48) in C:\xampp\htdocs\aresV2\admin\ProdTypes.php on line 51
