Jump to content

Displaying results from MySQL DATE_FORMAT()


PWD

Recommended Posts

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:

[b]Table:[/b] imp_dates
[b]Field 1:[/b] date_date DATE not null
[b]Field 2:[/b] date_info varchar 250 not null

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

[code]<?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());
?>[/code]

My static webpage:

[code]/* 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

}

?>[/code]

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

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.