Rifts Posted November 10, 2010 Share Posted November 10, 2010 hey guys so I have this code: $result = mysql_query("SELECT * FROM pec_mssgs ORDER BY (y / m) DESC, d ASC"); while($row = mysql_fetch_array($result)) { echo "•<a style='text-decoration: underline; font-weight: bold;' href='../index?id=".$row['id']."'>". $row['m']."/".$row['d']."/".$row['y'] . " - ".$row['title']."</a>"; echo "<br /><br />"; } in my database instead of doing date I have 3 rows d, m, y, which correlate to day, month, year. now currently its echo out a list and sorting by year then month then day this way the events which are happening soonest will be at top. the problem is it shows events that has already passed. what do I do? It will be way to much work to to back and recode the application to just use date. is there a way I can create a var. using my d/m/y then compare that var. to the current date or something? thanks for the help. Link to comment https://forums.phpfreaks.com/topic/218306-only-show-event-is-day-had-not-passed-hard/ Share on other sites More sharing options...
dheeraja Posted November 11, 2010 Share Posted November 11, 2010 It will be much better if you take a single field to database say "date" and its data type should be date, now store dates in the format of yyyy-mm-dd so you can just directly compare the dates and you can easily sort your record according to date.. Thank you Dheeraj Link to comment https://forums.phpfreaks.com/topic/218306-only-show-event-is-day-had-not-passed-hard/#findComment-1132915 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.