Kerry_7777 Posted October 12, 2009 Share Posted October 12, 2009 I have been building a webpage to display upcoming events. The date is displayed on the page as year/month/day. Arggghhh!!! I need to reverse the format. Have tried lots of things but cant get it to work. Also I want to display the highest dates in the table but put the events in normal upcoming order. Please see my code below: <?php require_once '******.inc.php'; $query = 'select date, name, time, venue, info from tbl***** order by date DESC LIMIT 0,5'; $result = mysql_query($query); if (!$result) { exit("Error retrieving courses from database"); } if (mysql_num_rows($result) <1) { exit("No courses records found "); } ?> <table> <tr> <th>Name</th> <th>Date</th> <th>Time</th> <th>Venue</th> <th>Information</th> </tr> <?php while ($row = mysql_fetch_array($result)) { $Name = $row['name']; $Date = $row['date']; #WHAT DO I DO HERE? $Time = $row['time']; $Venue = $row['venue']; $Info = $row['info']; ?> <tr> <td><p><?= $Name; ?></p></td> <td><p><?= $Date; ?></p></td> <td><p><?= $Time; ?></p></td> <td><p><?= $Venue; ?></p></td> <td><p ><?= $Info; ?></p></td> </tr> <?php } ?> </table> Quote Link to comment Share on other sites More sharing options...
taquitosensei Posted October 12, 2009 Share Posted October 12, 2009 first of all use php tags it makes it much easier to read. if your date column is a datetime value you could do this $query = 'select date_format(date,'%d/%m/%Y') as date, name, time, venue, info from tbl***** order by date DESC LIMIT 0,5'; or in php $formatted_date=date("d/m/Y", strtotime($row['date'])); 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.