Hi i have this code which allows me to retrive the date and change the format that is displayed but now when i use the update form it sets the date back to 0000/00/00
this the retrive code works fine
$query = "SELECT *, DATE_FORMAT(news_date, '%m/%d/%Y') as new_date FROM news WHERE news_id = '$news_id' ";
but now how can i do the same to update
i tried just change the SELECT to update but give an error so i wana vice verse the date back to its original format when it send back to mysql databse but keep the format a
Doesnt work help please??
$query = "UPDATE*, DATE_FORMAT(news_date, '%m/%d/%Y') as new_date FROM news WHERE news_id = '$news_id' ";
news_id news_date subject news_artical
70 00/00/0000 sun its bright
<?php
//Get the key field to be amended
$news_id = $_GET['news_id'] ;
$news_date = $_GET['news_date'] ;
$subject = $_GET['subject'];
$news_artical = $_GET['news_artical'];
// check if there were any errors
$query = "UPDATE news SET news_date = STR_TO_DATE('$mynewdatevalue','%Y/%m/%d'), subject='$subject', news_artical='$news_artical' WHERE news_id = '$news_id'";
// execute query
print "<p>The following records has been updated: </p>";
$result = mysql_query($query) ;
//if there was a problem - get the error message and go back
if (!$result)
{
echo "There were errors :<br>". mysql_error();
}
else //OK, then the insertion was successful
{
//Create a new query to display the new row in a table
$query = "SELECT * FROM news WHERE news_id = '$news_id'";
$result = mysql_query($query) or die ("Error in query: $query. ".mysql_error());
echo "<table cellpadding=10 border=1>";
while($row = mysql_fetch_array($result)) {
echo "<tr>";
echo "<td>".$row["news_id"]."</td>";
echo "<td><strong>" .$row["news_date"]."</strong></td>";
echo "<td><strong>".$row["subject"]."</strong></td>";
echo "<td width='55%'>".$row["news_artical"]."</td>";
echo "</tr>";
} //End while
echo "</table>";
} //End Else insertion successful
//End else successful Amendment
?>