Custom sort for 2-dimensional array
Posted: Mon May 24, 2010 9:55 pm
I'm doing two db queries and combining the results of both into an array of the rows. Specifically, there is a table for todo-list items and their duedates, and a table for reminders and their dates/repeat schedules, and I want to display data from both tables on a calendar-type thing.
I can order the rows within each query as I want, but I want to order them across both queries, so I'm going to need a custom sort function (I think) for the array. Basically I want to order each row within the main array by the strtotime value of its 'datetime' value, so the row with $row['datetime'] as the lowest would appear first, and the highest would appear last.
What's the best way of doing this? Or, how can I query both tables within the same mysql_query function and order by `li_datetime` in the todo list table, and also `rm_datetime` in the reminders table?
Thanks.
I can order the rows within each query as I want, but I want to order them across both queries, so I'm going to need a custom sort function (I think) for the array. Basically I want to order each row within the main array by the strtotime value of its 'datetime' value, so the row with $row['datetime'] as the lowest would appear first, and the highest would appear last.
What's the best way of doing this? Or, how can I query both tables within the same mysql_query function and order by `li_datetime` in the todo list table, and also `rm_datetime` in the reminders table?
Thanks.