you can't really make a gallery like your talking about with PHP, at least I think. you need ajax or JS or the page will reload and jump around which is a poor design for a gallery. And far as the page.php?pic=2 can be almost anything you want it to be. Id's for queries and such or a pic but then you need code to choose and load the pic. Jquery would be good for a gallery. There are many plug-ins and has classess dedicated to ajax
You can use Apache mod rewrite to allow this type of thing (I think) in the url, but it's not a standard pattern that I've seen.