How to Make Flash 8 wait for variable value from php?

I am having flash load a php file via loadVariable() method.

but the php file checks for a particular thing from my MySQL Server and then yeilds out a value. How can i have flash wait for this value to come and then proced with the actionscript after the value is recieved. my attepts were something like this:

With the do…while loop.
var rowNum:Number = 0;

do {
trace(rowNum); //this is just for evaluation purpose
} while (rowNum==0)

trace(rowNum);
//and the rest of the script…

**With the If…Then Loop
**var rowNum:Number = 0;

if (rowNum==0)
{
trace(rowNum);
gotoAndPlay(2) //2 was the previous frame which did not have the stop command.
{
else
{
trace(rowNum);
gotoAndPlay(4) //where the rest of the script was waiting for this.
}

and i always got 0 for rowNum and did not get the value from PHP. what can i do?
thanx in advance guys!