Welcome Guest, Not a member yet? Register   Sign In
Help with query structure, upcoming events and birthdays (two separate tables)
#1

[eluser]JamieBarton[/eluser]
Hi folks,

Question time!

I'm working on a block on my dashboard that is to highlight the <B>5</B> upcoming events and birthdays.

The events are stored in a table called 'events' and the birthdays are stored in the user profile, in the field called 'birth_date'.

I want to query the database and select all events and birthdays that are upcoming in the 7 days (limiting displaying by 5 remember if there are more than 5) and to show the events in order of the date.

When looping through them I want to be able to show the following: http://grab.by/2zhL

As you can see the event name is just shown along with an event icon and a birthday icon along with the users name.

Can anybody help pushing me in the right lines for this?

So far, which I think will need scrapping is the following which just gets events (family_id is another WHERE i need to have in the getting events and users):

Code:
function get_upcoming_events($family_id, $limit=5, $daystoadd=7)
    {
        $now = date("Y-m-d H:i");
        $this_week = date("Y-m-d H:i", mktime(date("H"),date("i"),0,date("m"),date("d")+$daystoadd,date("Y")));
        
        $this->db->limit($limit);
        $this->db->where('family_id', $family_id)
                 ->where('end_time <=',$this_week)
                 ->where('start_time >=', $now);

        return $this->db->get('events');
    }

Any help would be greatly appreciated.


Messages In This Thread
Help with query structure, upcoming events and birthdays (two separate tables) - by El Forum - 02-21-2010, 07:42 AM



Theme © iAndrew 2016 - Forum software by © MyBB