Following initialization of PageNumber Variable ($PageNumber=1;)needs to be moved to AFTER include('includes/PDFStarter.php'); because it is set back to 0 in that include.