Hi Merlin, I think that you could do a table with the periods such as ID Star End is_free 1 1.12 14.12 1 2 4.12 18.12 0 3 5.12 19.12 0 then you can search the first period free with a query Mysql $sql = "SELECT id FROM periods where is_free = '1' order by id asd" i hope that i have helped you Gerardo Benitez. On Thu, Dec 3, 2009 at 5:26 AM, Merlin Morgenstern <merlin_x@xxxxxxxxxxx>wrote: > Hello everybody, > > I am pretty much stuck with a problem and I was hoping to find some help > here with you guys. > > A PHP Script with MySQL as DB has to find out the first possible booking > period available. I can't figure out the logic behind and if there is a > trick with PHP to do it. > > Following facts: > - There can only be 3 bookings in the same time period > - I want to find out the first period available > - There should be a less as possible periods that are unbooked > > Example: > Start End > 1.12 14.12 > 4.12 18.12 > 5.12 19.12 > In this example the first possible booking would be 14.12 - 28.12 as this > is a time period where I can offer a place that holds a max of 3 bookings. > > My Problem now is how to pull this info and process it? > > Should I get all dates out of the DB and process them via PHP, or do a > magical MYSQL Query (which by the way seems not to be possible in that case > in my knowledge) ? > > Let's asume we go with PHP. Has somebody an idea how to form that kind of > logic? > > Thank you for ANY help, > > merlin > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- Gerardo Benitez