$var1 = 0; function search($text) { mysql search .... while ... results .. $var1++ } $text = "hi"; search($text); echo "$var1 Results Have been Found"; //It only displays 0, and it doesnt count the loops and the additions in the function