how to mix two arrays into one and sort it by date/time?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I have two tables with orders of different type of articles.
order_table_1
order_table | order_transaction_no | order_date | ...
1 | 56982 | 2005-07-29 9:12:34
1 | 97163 | 2005-07-30 8:45:32
1 | 67452 | 2005-07-31 10:56:11

order_table_2
order_table | order_transaction_no | order_date | ...
2 | 36928 | 2005-07-29 11:12:54
2 | 97001 | 2005-07-29 4:45:41
2 | 54549 | 2005-07-31 6:56:28

I have to grab orders from both tables (last 24 hour), put them together and then sort them by datetime ordered. Like this:
2 | 97001 | 2005-07-29 4:45:41
1 | 56982 | 2005-07-29 9:12:34
2 | 36928 | 2005-07-29 11:12:54
1 | 97163 | 2005-07-30 8:45:32
2 | 54549 | 2005-07-31 6:56:28
1 | 67452 | 2005-07-31 10:56:11

My idea was to grab first all orders from first table as multi-dimensional array
$orders = array(
array('order_table' => 1, 'order_trans_no' => 56982, 'order_date' => 2005-07-29 9:12:34), array('order_table' => 1, 'order_trans_no' => 97163, 'order_date' => 2005-07-30 8:45:32), array('order_table' => 1, 'order_trans_no' => 67452, 'order_date' => 2005-07-31 10:56:11) array('order_table' => 2, 'order_trans_no' => 36928, 'order_date' => 2005-07-29 11:12:54), array('order_table' => 2, 'order_trans_no' => 97001, 'order_date' => 2005-07-29 4:45:41), array('order_table' => 2, 'order_trans_no' => 54549, 'order_date' => 2005-07-31 6:56:28)
           )

and then sort the array after order_date - but don't know how :(

I guess the best way would be to make a sql query and sort them while grabbing them from db but don't know how to do it either :(

Any help?

Thanks!

-afan

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux