Rpm problems on 1994 Mazda 626

What is going on with my car. As I was getting ready to crank up my car it wouldn't start so I had to tap the battery a couple times then it started. Now I as im driving and i notice my car was acting funny and I looked at the rpm it was high then drops low. I just replaced the Mass Air Flow (just 3 days ago) and still having problems. What you think the problem maybe, pleas don't tell me its the transmission problems. If thats the case I may as well purchase a new car, but hell my balance on the car is $1200!

Asked by for the 1994 Mazda 626
If you had to tap on the battery to get the engine to crank, then you have a faulty battery or battery terminal connection. You need to get the battery problem fixed first, your car will not run right with an intermittent battery or battery terminal connection. While you're at it, check the intake duct for leaks, like loose clamps or a crack in the rubber air duct. Make sure the air filter enclosure is closed properly and the air filter's clean. Next, if you haven't replaced the fuel filter in recent memory, replace it and look for contamination in the fuel that spills out of it.
If all is good, and the car still doesn't run right, it's time for a Mazda specialist. Here's a directory link for you:
PS: nest time, please let us know whether your car has an automatic transmission or a manual, the control systems are different.
thanks buddy i'll check into now. and sorry its a automatic