Jump to content

[SOLVED] Date_Format Problem


mtmrop

Recommended Posts

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!

Link to comment
https://forums.phpfreaks.com/topic/171535-solved-date_format-problem/
Share on other sites

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>";
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.