downah Posted March 28, 2012 Share Posted March 28, 2012 Hey guys, I have got some events, and got it sorted by date, although at the moment the oldest date is showing first, and I would like to turn that around(new first old last), any simple suggestions? Also another little question how would I turn a date row (for example 2009/5/31) into Tuesday - May 2009 or something similar, anyone can point me into the right direction? Quote Link to comment Share on other sites More sharing options...
seanlim Posted March 28, 2012 Share Posted March 28, 2012 How is the data structured? Array of OOP objects in PHP? Rows in MySQL? Assuming the former since this is a PHP forum, you can use usort on the array and define your own function to sort by date. Read the manual for more information about writing a user-defined sort function. Quote Link to comment Share on other sites More sharing options...
downah Posted March 28, 2012 Author Share Posted March 28, 2012 $result = mysql_query("SELECT * FROM Events ORDER BY eventdate"); echo "<table border='0'> <tr> <th>Date/Time</th> <th>Event</th> <th>Participants</th> <th>Hoster</th> </tr>"; while($row = mysql_fetch_array($result)) { echo "<tr>"; echo "<td>" . $row['eventdate'] . " " . $row['starttime'] . "</td>"; echo '<td><a href="showevent.php?eventsID='; echo $row['eventsID']; echo '">'; echo $row['eventdescriptionheader']; echo "</a></td>"; echo "<td>" . $row['currentparticipants'] . "/" . $row['maxparticipants'] . "</td>"; echo "<td>" . $row['hoster'] . "</td>"; echo "</tr>"; } echo '</table>'; } ?> eventdate is a date field in MYSQL Quote Link to comment Share on other sites More sharing options...
downah Posted March 28, 2012 Author Share Posted March 28, 2012 By adding DESC after order by date it done what was needed ill post up another topic containing my other question Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.