j201 Posted December 29, 2008 Share Posted December 29, 2008 Hi there, using MYSQL version 5.0. I'm trying to display 2 different sets of dates (registration dates from a forum and old registration dates from a former forum) in one list in chronological order. So far everything works fine except having them be in the same list together. $membersql = "SELECT * FROM members ORDER BY old_date, register_date;"; $memberres = mysql_query($membersql); Gets the dates across the user base. $current = date("z"); $check = date("Y"); $limit = date("z")+30; while($memberrow = mysql_fetch_assoc($memberres)) { $join = date("z", strtotime($memberrow['register_date'])); $join2 = date("z", strtotime($memberrow['register_date']))+365; $joincheck = date("Y", strtotime($memberrow['register_date'])); Used later to limit the actual output to only dates within 30 days of today, and starts the while loop. if($current <= $join && $join <= $limit || $join2 <= $limit) { if($check != $joincheck) { echo "<div>(new) ".$memberrow['name'].": "; echo date("n/j", strtotime($memberrow['register_date']))."</div>"; } } Checks if the normal join date is within 30 days, and outputs the user name if so. if($memberrow['old_date'] != NULL) { $old = date("z", strtotime($memberrow['old_date'])); $old2 = date("z", strtotime($memberrow['old_date']))+365; if($current <= $old && $old <= $limit || $old2 <= $limit) { echo "<div>(old) ".$memberrow['name'].": "; echo date("n/j", strtotime($memberrow['old_date']))."</div>"; } } } Same thing, only for the old registration date. Right now that outputs: <div>(new) Username1: 12/31</div> <div>(new) Username2: 1/4</div> <div>(new) Username3: 1/12</div> <div>(old) Username4: 1/1</div> <div>(old) Username5: 1/6</div> Whereas I need: <div>(new) Username1: 12/31</div> <div>(old) Username4: 1/1</div> <div>(new) Username2: 1/4</div> <div>(old) Username5: 1/6</div> <div>(new) Username3: 1/12</div> All help is appreciated. Link to comment https://forums.phpfreaks.com/topic/138710-mysql-query-2-in-1-issue/ Share on other sites More sharing options...
j201 Posted December 30, 2008 Author Share Posted December 30, 2008 Bumping as a day has passed. Link to comment https://forums.phpfreaks.com/topic/138710-mysql-query-2-in-1-issue/#findComment-726063 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.