Theres no such thing as running php in "offline mode". All you do is changing some variables to the apache's conf file to be run in localhost...
Basically, install apache on your machine, and then configure this directive
ServerName 127.0.0.1
(And obviously, configure it to have support for php, google for it)
Also, If you need to access a DB, you need to install it in your machine, that way, you have a full local development environment, and wont need to connect to internet anymore...
You say you get an error that localhost cannot be connected, it means
"Sorry, but theres no application running at port 80", aka, theres no webserver installed (or started in case you already installed it)