LanceT Posted June 1, 2009 Share Posted June 1, 2009 So I am creating a new RSS feed that takes contents from two different mysql tables. I am using the following code $query = "select dateline, url, title, description,rssdate from `articles` WHERE pagenumber='1' ORDER by id DESC limit 15"; $result = mysql_query($query, $dbh); while ($line = mysql_fetch_assoc($result)) { $return[] = $line; } $query2 = "select dateline, link_url, title, category, rssdate from `rotator` WHERE category='movie' ORDER by id DESC limit 5"; $result2 = mysql_query($query2, $dbh); while ($line2 = mysql_fetch_assoc($result2)) { $return[] = $line2; } I want to have the resulting array ($return) sorted by "dateline" (which is a number that organizes the dates of each item). Now how do I go about sorting this array? Thanks Link to comment https://forums.phpfreaks.com/topic/160530-sorting-two-mysqls-into-one-array-by-the-date/ Share on other sites More sharing options...
roopurt18 Posted June 1, 2009 Share Posted June 1, 2009 Why don't you just use a UNION in MySQL and have the database sort it? Then you only need to make one database call. Link to comment https://forums.phpfreaks.com/topic/160530-sorting-two-mysqls-into-one-array-by-the-date/#findComment-847340 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.