Jump to content


Photo

Displaying results from MySQL DATE_FORMAT()


  • Please log in to reply
3 replies to this topic

#1 PWD

PWD
  • Members
  • PipPip
  • Member
  • 19 posts

Posted 07 March 2006 - 05:09 AM

I must be missing something basic and I have had 2 hours of sleep the last two days trying to figure this DATE_FORMAT function out...

My Table Structure:

Table: imp_dates
Field 1: date_date DATE not null
Field 2: date_info varchar 250 not null

My basic query (which is an include since this information is accessed on more than a dozen pages):

<?php
$connect = mysql_connect("localhost","User","Pass")
    or die("<h1>Invalid Username and/or Password</h1>");

mysql_select_db("data")
    or die("<h1>Could Not Connect to Database</h1>");

$query = "Select DATE_FORMAT('date_date','%b %d %Y') AS date_date,date_info from imp_dates ORDER BY date_date ASC";
$result = mysql_query($query)
    or die(mysql_error()); 
?>

My static webpage:

/* html markup */
<?php

while($row = mysql_fetch_assoc($result)) {
extract($row);


 ?>

/*Some html mark up*/

<li><?php echo $date_date; ?></li>
<li><?php echo $date_info; ?></li>

<?php

}

?>

The date doesn't display AT ALL, but the info. snippet does...I'm simply trying to display the date in a format that is easier to read than int'l date format using the DATE_FORMAT() function. Where am I going wrong?

My gratitude ahead of time for helping me learn...again...
[!--fonto:Geneva--][span style="font-family:Geneva"][!--/fonto--]My Gratitude---[!--fontc--][/span][!--/fontc--]
(My gratitude in advance for helping me learn; so I may one day give as freely as you have here today)
----------
[!--sizeo:5--][span style="font-size:18pt;line-height:100%"][!--/sizeo--][!--fonto:Optima--][span style="font-family:Optima"][!--/fonto--][!--coloro:red--][span style="color:red"][!--/coloro--]PWD[!--sizec--][/span][!--/sizec--][!--colorc--][/span][!--/colorc--][!--fontc--][/span][!--/fontc--]

#2 DylanBlitz

DylanBlitz
  • Members
  • PipPipPip
  • Advanced Member
  • 99 posts
  • LocationOC Baby!

Posted 07 March 2006 - 05:17 AM

$query = "Select DATE_FORMAT(date_date,'%b %d %Y') AS date_date,date_info from imp_dates ORDER BY date_date ASC";

No quotes in the field name :)

#3 PWD

PWD
  • Members
  • PipPip
  • Member
  • 19 posts

Posted 07 March 2006 - 05:21 AM

DOH!

Thank you for the second pair of eyes!

[!--sizeo:3--][span style=\"font-size:12pt;line-height:100%\"][!--/sizeo--]Can I express my gratitude enough?
[!--sizec--][/span][!--/sizec--]

Works perfectly...
[!--fonto:Geneva--][span style="font-family:Geneva"][!--/fonto--]My Gratitude---[!--fontc--][/span][!--/fontc--]
(My gratitude in advance for helping me learn; so I may one day give as freely as you have here today)
----------
[!--sizeo:5--][span style="font-size:18pt;line-height:100%"][!--/sizeo--][!--fonto:Optima--][span style="font-family:Optima"][!--/fonto--][!--coloro:red--][span style="color:red"][!--/coloro--]PWD[!--sizec--][/span][!--/sizec--][!--colorc--][/span][!--/colorc--][!--fontc--][/span][!--/fontc--]

#4 DylanBlitz

DylanBlitz
  • Members
  • PipPipPip
  • Advanced Member
  • 99 posts
  • LocationOC Baby!

Posted 07 March 2006 - 05:23 AM

not a problem, sometimes it just takes someone else to see it, happens to me all the time :)




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users