Look at my code, I use foreach to get value from a query result, then use each value to get a query result, if $sql2 echo something, then it will run. But how about if none of of $sql2 echo a result, then I want to do something else outside the foreach loop? how to check if no $sql2 result at all?