change date format on multiple update
I need to display dates in 'd F Y' format and this is the format that users will input dates into the database. When inserting them in a single insert/update I use:
".((!empty($_POST["DateAdded"]))?date("Y-m-d", strtotime($_POST["DateAdded"])):"") ."
to convert the date back into the format for the database to store it.
The problem is with multiple inserts/updates I can display it in the correct format but how do I upload the date and change it to Y-m-d?
This is my code:
<?php
// WA DataAssist Multiple Updates
if (isset($_POST["Update_x"])) // Trigger
{
if (!session_id()) session_start();
$WA_loopedIDField = array("WADA_RepeatID_ConversationID");
$WA_connection = $flybuy;
$WA_table = "Conversation";
$WA_redirectURL = "";
$WA_keepQueryString = false;
$WA_indexField = "ConversationID";
$WA_fieldNamesStr = "DateAdded|Type|Type2|HandledBy|ConText|Action";
$WA_columnTypesStr = "',none,NULL|',none,''|',none,''|',none,''|',none,''|',none,''";
$WA_fieldNames = explode("|", $WA_fieldNamesStr);
$WA_columns = explode("|", $WA_columnTypesStr);
$WA_connectionDB = $database_flybuy;
$WA_multipleUpdateCounter = 0;
mysql_select_db($WA_connectionDB, $WA_connection);
while (WA_AB_checkLoopedFieldsNotBlank($WA_loopedIDField, $WA_multipleUpdateCounter)) {
$WA_fieldValuesStr = "".WA_AB_getLoopedFieldValue("DateAdded2", $WA_multipleUpdateCounter) ."" . "|" . "".WA_AB_getLoopedFieldValue("Type", $WA_multipleUpdateCounter) ."" . "|" . "".WA_AB_getLoopedFieldValue("Type2", $WA_multipleUpdateCounter) ."" . "|" . "".WA_AB_getLoopedFieldValue("HandledBy", $WA_multipleUpdateCounter) ."" . "|" . "".WA_AB_getLoopedFieldValue("ConText", $WA_multipleUpdateCounter) ."" . "|" . "".WA_AB_getLoopedFieldValue("Action", $WA_multipleUpdateCounter) ."";
$WA_fieldValues = explode("|", $WA_fieldValuesStr);
$WA_where_fieldValuesStr = WA_AB_getLoopedFieldValue($WA_loopedIDField[0], $WA_multipleUpdateCounter);
$WA_where_columnTypesStr = "none,none,NULL";
$WA_where_comparisonStr = "=";
$WA_where_fieldNames = explode("|", $WA_indexField);
$WA_where_fieldValues = explode("|", $WA_where_fieldValuesStr);
$WA_where_columns = explode("|", $WA_where_columnTypesStr);
$WA_where_comparisons = explode("|", $WA_where_comparisonStr);
$updateParamsObj = WA_AB_generateInsertParams($WA_fieldNames, $WA_columns, $WA_fieldValues, -1);
$WhereObj = WA_AB_generateWhereClause($WA_where_fieldNames, $WA_where_columns, $WA_where_fieldValues, $WA_where_comparisons );
$WA_Sql = "UPDATE `" . $WA_table . "` SET " . $updateParamsObj->WA_setValues . " WHERE " . $WhereObj->sqlWhereClause . "";
$MM_editCmd = mysql_query($WA_Sql, $WA_connection) or die(mysql_error());
$WA_multipleUpdateCounter++;
}
if ($WA_redirectURL != "") {
if ($WA_keepQueryString && $WA_redirectURL != "" && isset($_SERVER["QUERY_STRING"]) && $_SERVER["QUERY_STRING"] !== "" && sizeof($_POST) > 0) {
$WA_redirectURL .= ((strpos($WA_redirectURL, '?') === false)?"?":"&").$_SERVER["QUERY_STRING"];
}
header("Location: ".$WA_redirectURL);
}
}
?>