The code seems to be wrong (sql portion).
As you said, you need the user data as well as arear data, I don't see any data you considered from arear,
So, you need to change your sql like
SELECT * FROM userdata U, arear A where U.uid=A.uid
Second thing, you can make your code more robust, is to write the sql to get day/month.
So, you don't need to add a logic in the loop.
This part I leave it to you.
Hope this helps.
cheers