I was conflicted on whether to post this on WP Answers or here because I'm talking about wp\_Queries, but I think this is more of a general PHP question, so here goes.

I am building an event calendar function in a project. What I have so far can be seen here, if you need a visual: <http://theseattlevine.com/wordpress2014/calendar/?m=Feb&y=2014>

The number of days (represented by squares, like a normal calender) is generated using query args that communicate with the date() and strtotime() functions which generates the proper amount of days in the month and starts the month on the proper day (Mon-Sun). I am using a for loop to generate the squares a finite numbers of times based on the number of days in each month.

Now, inside each square I want to, obviously, have a list of events happening on that day. The most logical way in my brain to do this is to have a query loop in each square that finds all the events with dates falling between 12:00am and 11:59pm on that day, then just echo out the title of each one. But, it doesn't seem like this type of query works inside a for loop, and the research that I've done leads me to believe putting a loop inside a for loop is a bad idea because it creates a large number or requests on the server.

**My question, finally, is what is the best method to do this then? How would I query posts from a database (like wp\_query in Wordpress) inside of each occurrence of a for loop?**