hmm...well I'm not sure I know what you're talking about, but at the end of the code, you're making a boolean comparison and not an assignment.
$cnt==0;
php says, okay, true or false
$cnt=0;
php says, oh, I'll assign the number 0 to the variable cnt
and if you want to pass the variable back, just put it in the URL and then request it.