crag Posted April 8, 2006 Share Posted April 8, 2006 I am using this code to output the formatted date to screen which produces the result:"Saturday 1st April" for example.[code]<?php include_once 'db.inc.php'; // Display all gig listings to page.$result = @mysql_query('SELECT id, bandname, giginfo, gigtime, DATE_FORMAT(gigdate, "%W %D %M") AS gigdate FROM giglist ORDER BY gigdate');if(!$result) { exit ('<p>Error performing query ' . mysql_error() . '</p>');} while($row = mysql_fetch_array($result)) { $gigid = $row['id']; $bandname = htmlspecialchars($row['bandname']); $giginfo = htmlspecialchars($row['giginfo']); $gigtime = htmlspecialchars($row['gigtime']); $gigdate = $row['gigdate']; echo '<fieldset><p><b>' . $gigdate . ' | ' . $bandname . '<br /></b>' . $giginfo . '<br /><b>' . $gigtime . '</b></p></fieldset><br />'; } ?>[/code]My problem is when using "ORDER BY gigdate" it orders by the day (Saturday) and not the actual full date itself so giving me the result where all mondays are grouped together then tuesdays and so on.Also in my form:[code]<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> <p><label>Enter date:</label><input name="gigdate" type="text" size="20" maxlength="20" /></p> <p><label>Enter band name:</label><input name="bandname" type="text" size="40" maxlength="40" /> <p><label>Enter gig details:</label><textarea name="giginfo" cols="50" rows="10"></textarea></p> <p><label>Enter gig time:</label><input name="gigtime" type="text" size="20" maxlength="20" /></p> <p><input name="submit" type="submit" value="submit" class="submit" /></p></form>[/code]I have to enter the date as YYYY/MM/DD where I would like the user to be able to enter the date as DD/MM/YYY.Can anyone tell me how to achieve this?Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/6878-solved-order-by-problem/ Share on other sites More sharing options...
crag Posted April 8, 2006 Author Share Posted April 8, 2006 I managed to work it out for myself - maybe I should have tried harder in the first place before posting here.A lesson learnt Quote Link to comment https://forums.phpfreaks.com/topic/6878-solved-order-by-problem/#findComment-25053 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.