changing loop vars to consistent naming
changing templates to GLOBALS style
changing over to mysqli usage
changing over to mysqli usage
changing over to mysqli usage