Update Multiple Records that include file upload
I have successfully created an update form that includes a file upload.
I also need to create a multiple record update that does the same thing. Everything works with the exception of the file field. On submitting the form, the db table gets an empty entry. Plus the server validations are not working, probably because I am using the same validation code as the single update record.
Is there a different technique when doing this for multiple records than for single records?
Below is the WU Update code:
<?php
// WA DataAssist Multiple Updates
if (isset($_POST["Update_x"])) // Trigger
{
if (!session_id()) session_start();
$WA_loopedIDField = array("WADA_RepeatID_pFolioImg_id");
$WA_connection = $joshHannaDB;
$WA_table = "pFolioImage_Joshua";
$WA_redirectURL = "pFolioImage_Joshua_Results.php";
$WA_keepQueryString = false;
$WA_indexField = "pFolioImg_id";
$WA_fieldNamesStr = "pFolioImg_CatID|pFolioImg_Filename|pFolioImg_Title|pFolioImg_Details|showAsRecent|pFolioImg_UdateDate|pFolioImg_Active";
$WA_columnTypesStr = "none,none,NULL|',none,''|',none,''|',none,''|',none,''|',none,NULL|',none,''";
$WA_fieldNames = explode("|", $WA_fieldNamesStr);
$WA_columns = explode("|", $WA_columnTypesStr);
$WA_connectionDB = $database_joshHannaDB;
$WA_multipleUpdateCounter = 0;
mysql_select_db($WA_connectionDB, $WA_connection);
while (WA_AB_checkLoopedFieldsNotBlank($WA_loopedIDField, $WA_multipleUpdateCounter)) {
$WA_fieldValuesStr = "".WA_AB_getLoopedFieldValue("pFolioImg_CatID", $WA_multipleUpdateCounter) ."" . "|" . "".$WA_DFP_UploadStatus["WA_UploadResult1"]["serverFileName"] ."" . "|" . "".WA_AB_getLoopedFieldValue("pFolioImg_Title", $WA_multipleUpdateCounter) ."" . "|" . "".WA_AB_getLoopedFieldValue("pFolioImg_Details", $WA_multipleUpdateCounter) ."" . "|" . "".WA_AB_getLoopedFieldValue("showAsRecent", $WA_multipleUpdateCounter) ."" . "|" . "".WA_AB_getLoopedFieldValue("pFolioImg_UdateDate", $WA_multipleUpdateCounter) ."" . "|" . "".WA_AB_getLoopedFieldValue("pFolioImg_Active", $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);
}
}
?>
And here is the validation code:
<?php
if (isset($_POST["Update_x"])) {
$WAFV_Redirect = "portfolioJoshua_updateMulti.php?invalid=true";
$_SESSION['WAVT_portfolioJoshuaupdateMulti_632_Errors'] = "";
if ($WAFV_Redirect == "") {
$WAFV_Redirect = $_SERVER["PHP_SELF"];
}
$WAFV_Errors = "";
$WAFV_Errors .= WAValidateNM(((isset($_FILES["portfolioImage"]))?$_FILES["portfolioImage"]["size"]:"") . "",0,1500000,"",",.",false,1);
$WAFV_Errors .= WAValidateFE(((isset($_FILES["portfolioImage"]))?$_FILES["portfolioImage"]["name"]:"") . "",".gif, .jpg, .jpeg, .png",false,2);
if ($WAFV_Errors != "") {
PostResult($WAFV_Redirect,$WAFV_Errors,"portfolioJoshuaupdateMulti_632");
}
}
?>
I have also attached the actual page.
Any help will be greatly appreciated.