mtmrop Posted August 23, 2009 Share Posted August 23, 2009 Hi folks, sorry to drag up what appears to be a recurrent topic, but i'm stuck on a date_format and need some help. I need to run a query accross 2 tables in a database (booking and music). The query is working fine, returning exactly the right information in the right order (i.e. bDate in ascending order). However, when it comes to echo the bDate value in the PHP script, nothing is happening. The only way I can get it to display anything is to remove the date_format and just settle for the field name. At that point it echo's the date in YYYY-MM-DD format which is no use to me! Can anyone tell me what i've done wrong? $booking = mysql_query("SELECT b.bName, date_format(b.bDate,'%D %M') as Date, m.bDesc, m.bURL, m.bPic FROM music AS m INNER JOIN booking as b USING(bName) WHERE b.bActive='on' ORDER BY b.bDate ASC"); ?> <table width="100%" border="0"> <col width="50%"> <col width="50%"> <?php while ($row = mysql_fetch_array($booking)) { echo "<tr>"; echo "<td>" . $row['bName'] . "</td>"; echo "<td style=align:right>" . $row['bDate'] . "</td>"; //code continues Thanks to anyone who can help! Quote Link to comment https://forums.phpfreaks.com/topic/171535-solved-date_format-problem/ Share on other sites More sharing options...
PFMaBiSmAd Posted August 23, 2009 Share Posted August 23, 2009 date_format(b.bDate,'%D %M') as Date The alias name you used for the expression is how you would reference the data, $row['Date'] You can always display the whole array in $row to see what exactly it contains - <?php echo "<pre>"; print_r($row); echo "</pre>"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/171535-solved-date_format-problem/#findComment-904639 Share on other sites More sharing options...
mtmrop Posted August 23, 2009 Author Share Posted August 23, 2009 PFMaBiSmAd Thank you very much for the quick and accurate answer! Sorry for the very easy question - i'm new to PHP / mySQL, but reading, asking and learning Quote Link to comment https://forums.phpfreaks.com/topic/171535-solved-date_format-problem/#findComment-904645 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.