Sry for my bad English.
So the logic is:
1. Ajax Request on a Php file with some Parameters
2. Php file makes the database request and some magic stuff with the data
3. Ajax on complete, save the result in your global variables.
The other Problem is that Php is a server side language, it just makes something if you say "Hei Php go" and than it will execute your code one time, not more.
No other tool like Gamesalad, Gamemaker and so on can work with Php files without Ajax, Json and so on. Not even native code!