If your BMW cranks but doesn't always start you need to see if you are loosing fuel or spark. Get a friend to crank the engine and look for ignition spark. next you need to check for fuel (preferably checking fuel pressure and delivery). If you don't have fuel or ignition it could be many things. A computer in your car receives many signals from sensors on the engine, the computer interprets these signals and determines when and how long to turn on fuel injectors and ignition coils. Autozone have some popular workshop manuals for free on line once you register (for free) on their website http://bit.ly/autozone_repair_info or there is a company that independent auto repair shops "buy" their information from that offer a very reasonable service to do it yourselvers. You can get a one week subscription or year subscription very cheap. The information is year make and model specific repair procedures, service bulletins, component locations, wiring diagrams ect.... great quality information same as the professionals have ,much better than generic workshop manuals from parts stores, much cheaper than the factory manual try http://bit.ly/mitchell_repair_manuals_online
and get an online repair manual subscription.