Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.