Page 2 of 2

Posted: Mon Jan 26, 2004 2:09 pm
by John Cartwright
But using current_date will get the present value won't it,
I am inputting dates through a form.

Code: Select all

<?php
include("mysql.php"); 

echo "<div align="center">"
	."<form action="{$_SERVER['PHP_SELF']}"\n"
	."<p>Type your Date here: ( eg. Febuary 04 )<br/>\n" 
	."<textarea name="date" rows="1" cols="40" wrap></textarea><br/>\n" 
	."<p>Type your Description here here:<br/>\n" 
	."<textarea name="releasedesc" rows="10" cols="40" wrap></textarea><br/>\n" 
	."<input type="submit" name="submitreleases" value="SUBMIT" /></p>\n" 
	."</form>\n"
	."</div>";

$date = date('Y-m-d'); 

if ($submitreleases == "SUBMIT") { 
  $sql = "INSERT INTO releases SET date='$date', releasedesc='$releasedesc'";
	
if (@mysql_query($sql)) { 
    echo("<div align="center">Your News has been added.</div>"); 
  } else { 
    echo ("<div align="center">Error adding submitted news: " . mysql_error() . "</div>"); 
  } 
}

$result = @mysql_query("SELECT * FROM releases ORDER BY `date` DESC LIMIT 10");

$pastmonth = ""; // so that the first month always gets outputted. 
while ($row = mysql_fetch_array($result)) { 
   // store the two different date "things" you want to display. 
   $month = date("F", $row["date"]); // eg. February 
   $day = date("d", $row["date"]); // eg. 04 
   $year = date("y", $row["date"]); // eg. 2004
   if ($pastmonth != $month) { 
        echo $month."<br>"; 
   } 
   echo $day." - ".$row["releasedesc"]."<br>"; 
   $pastmonth = $month; // set the current month to the past month. 
} 
?>

BTW everything is being outputted as December 31.. the description part is working fine

2004-01-26 00:00:00 Is what is being stored in my database

Posted: Mon Jan 26, 2004 5:10 pm
by John Cartwright
anyone have anymore thoughts?

Posted: Tue Jan 27, 2004 8:08 am
by John Cartwright
up