Jump to content

Recommended Posts

im trying to change the date from default to Month Day, Year.  Basically the user fills out a form then i echo the results in a table but the date format that i got in my code didn't change the default date.  You can see what the output looks like at www.standridgemotorsports.com/jeremy_schedule1.php

below is the code.

 

thanks for any help.

 $result = mysql_query("SELECT *,DATE_FORMAT('h0237','%M-%d-%Y') FROM jos_jforms_72563 WHERE uid = 63 ORDER BY h0237 ASC");

echo "<table align='center' border='1'>
<tr>
<th>Date</th>
<th>Track</th>
<th>Description</th>
<th>Special Show</th>
<th>Race Type</th>
</tr>";

while($row = mysql_fetch_array($result))

  {
  echo "<tr>";
  echo "<td>" . $row['h0237'] . "</td>";//Date
  echo "<td>" . $row['h9ca9'] . "</td>";//Track
  echo "<td>" . $row['hf6a6'] . "</td>";//Description
  echo "<td>" . $row['h67d6'] . "</td>";//Special Show
  echo "<td>" . $row['heb76'] . "</td>";//Race Type
  echo "</tr>";
  }
echo "</table>";

 

Link to comment
https://forums.phpfreaks.com/topic/194728-displaying-date-different-from-default/
Share on other sites

A) Why are you using column names that don't convey the meaning of the column? That just makes writing code 10 times slower because you must keep looking-up and cross-referencing what they mean.

 

B) The DATE_FORMAT() term would need to be referenced as $row['DATE_FORMAT()'] if I remember correctly. You should use an alias name in the query, which is what you were shown in the solution in a previous thread on this same problem, which is why you should not keep starting new threads for the same problem. You would then reference the alias name $row['dt'] to access the formatted value.

 

C) There should be no single-quotes around the 'h0237' column name in the query as that would make it a string value instead of a column reference.

 

 

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.