num_rows == 0){ header("Location: create_category.php"); exit(); //It's good practice to call exit() after a redirect so nothing else gets executed. } while($row = mysqli_fetch_array($categories)) { } } else{ echo "Error"; } $db->close(); ?>