Is it possible to take the result from 4 different MySQL connections (assuming the query and the tables were the same for all 4), and then merge the results, AND sort the result before presenting it (without writing it back into the database, sorting it, and then exporting it again).
$query = "SELECT `Date`, `Result` FROM tablename;";
connect to Database 1 and run query => query1[]
connect to Database 2 and run query => query2[]
connect to Database 3 and run query => query3[]
connect to Database 4 and run query => query4[]
$full = array_merge(query1,query2,query3,query4);
then Print the result into a table, but Ordering it by the `Date` element.
Merge AND Order multiple MySQL Results in PHP
Moderator: General Moderators
Re: Merge AND Order multiple MySQL Results in PHP
Sure. Dump all the results into one array and usort it. Or if you want to do it smarter, use an insertion sort as you're adding.
Re: Merge AND Order multiple MySQL Results in PHP
.. or you can query your 4 DB's with a single query and apply your ORDER BY directly in that query... no further actions needed in PHP (array_merge or usort)
Edit: Assuming your DB's are in the same server
Edit: Assuming your DB's are in the same server