Thank you Jason, I better went with manage relational table behavior and file upload behavior from WA, but now I have the issues that the file upload behavior does not work and the relational table with the file element, erases the name of the file in the database if I don't pick an image when I'm updating the other elements. The page is supposed to update up to 6 pictures:
<?php
// WA_UploadResult1 Params Start
$WA_UploadResult1_Params = array();
// WA_UploadResult1_1 Start
$WA_UploadResult1_Params["WA_UploadResult1_1"] = array(
'UploadFolder' => "imagenes/",
'FileName' => "[FileName]",
'DefaultFileName' => "",
'ResizeType' => "0",
'ResizeWidth' => "0",
'ResizeHeight' => "0",
'ResizeFillColor' => "" );
// WA_UploadResult1_1 End
// WA_UploadResult1 Params End
?>
<?php
WA_DFP_SetupUploadStatusStruct("WA_UploadResult1");
if(isset($_POST["cambiar"]) || isset($_POST["cambiar_x"])){
WA_DFP_UploadFiles("WA_UploadResult1", "foto_1_".$RepeatSelectionCounter_1 ."", "2", "[NewFileName]_[Increment]", "false", $WA_UploadResult1_Params);
}
?>
<?php
// WA DataAssist Manage Relational Table 1
if (isset($_POST["cambiar"]) || isset($_POST["cambiar_x"])) // Trigger
{
$WA_arrayOrFieldList = 1;
$WA_joinLoopedField = "item_id";
$WA_loopedField = "WADA_RepeatID_fotoItemID";
$WA_connection = $musicosEC_CONN;
$WA_table = "fotos";
$WA_redirectURL = "";
if (function_exists("rel2abs")) $WA_redirectURL = $WA_redirectURL?rel2abs($WA_redirectURL,dirname(__FILE__)):"";
$WA_keepQueryString = false;
$WA_masterKeyField = "foto_bandID";
$WA_masterKeyType = "none,none,NULL";
$WA_masterKeyValue = "".$row_rsBanda['bnd_id'] ."";
$WA_masterKeyComp = "=";
$WA_joinedKeyField = "foto_fotoItemID";
$WA_joinedKeyType = "none,none,NULL";
$WA_joinedKeyComp = "=";
$WA_fieldNamesStr = "foto_bandID|foto_1|foto_fotoItemID";
$WA_columnTypesStr = "none,none,NULL|',none,''|none,none,NULL";
$WA_appliedString = "";
$WA_appliedList = array();
$WA_valuesList = array();
$WA_connectionDB = $database_musicosEC_CONN;
mysql_select_db($WA_connectionDB, $WA_connection);
if ($WA_arrayOrFieldList == 0) {
$WA_loopedValues = $_POST[$WA_joinLoopedField];
for ($v=0; $v<sizeof($WA_loopedValues); $v++) {
$WA_fieldValues = "^MASTERID^" . $WA_AB_Split . "".WA_AB_getLoopedFieldValue("foto_1", $WA_mrtLoopCounter) ."" . $WA_AB_Split . "^JOINID^";
$WA_valuesList[] = array($WA_loopedValues[$v], $WA_fieldValues);
$WA_appliedString .= "^" . $WA_loopedValues[$v] . "^";
$WA_appliedList[] = $WA_loopedValues[$v];
}
}
else if ($WA_arrayOrFieldList == 1) {
$WA_mrtLoopCounter = 0;
while (WA_AB_checkLoopedFieldsExist(array($WA_loopedField), $WA_mrtLoopCounter)) {
if (WA_AB_checkLoopedFieldsNotBlank(array($WA_joinLoopedField), $WA_mrtLoopCounter) && WA_AB_getLoopedFieldValue($WA_loopedField, $WA_mrtLoopCounter) == WA_AB_getLoopedFieldValue($WA_joinLoopedField, $WA_mrtLoopCounter)) {
$WA_fieldValues = "^MASTERID^" . $WA_AB_Split . "".WA_AB_getLoopedFieldValue("foto_1", $WA_mrtLoopCounter) ."" . $WA_AB_Split . "^JOINID^";
$WA_valuesList[] = array(WA_AB_getLoopedFieldValue($WA_loopedField, $WA_mrtLoopCounter), $WA_fieldValues);
$WA_appliedString .= "^" . WA_AB_getLoopedFieldValue($WA_loopedField, $WA_mrtLoopCounter) . "^";
$WA_appliedList[] = WA_AB_getLoopedFieldValue($WA_loopedField, $WA_mrtLoopCounter);
}
$WA_mrtLoopCounter++;
}
}
WA_AB_doManageRelationalTable($WA_valuesList, $WA_appliedString, $WA_appliedList, $WA_connection, $WA_table, $WA_masterKeyField, $WA_masterKeyType, $WA_masterKeyValue, $WA_masterKeyComp, $WA_joinedKeyField, $WA_joinedKeyType, $WA_joinedKeyComp, $WA_fieldNamesStr, $WA_columnTypesStr);
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);
}
}
?>
<?php
// RepeatSelectionCounter_1 Initialization
$RepeatSelectionCounter_1 = 0;
$RepeatSelectionCounterBasedLooping_1 = false;
$RepeatSelectionCounter_1_Iterations = "-1";?>
<?php
// WA DataAssist Pre-Select Relational Table 1
$WA_PreSelect_RelationalTable_1 = array();
$WA_connection = $musicosEC_CONN;
$WA_table = "fotos";
$WA_masterKeyField = "foto_bandID";
$WA_masterKeyType = "none,none,NULL";
$WA_masterKeyValue = "".$row_rsBanda['bnd_id'] ."";
$WA_masterKeyComp = "=";
$WA_joinedKeyField = "foto_fotoItemID";
$WA_connectionDB = $database_musicosEC_CONN;
mysql_select_db($WA_connectionDB, $WA_connection);
$WhereObj = WA_AB_generateWhereClause(array($WA_masterKeyField), array($WA_masterKeyType), array($WA_masterKeyValue), array($WA_masterKeyComp));
$WA_Sql = "SELECT ".$WA_masterKeyField.", ".$WA_joinedKeyField." FROM ".$WA_table." WHERE ".$WhereObj->sqlWhereClause." ORDER BY ".$WA_joinedKeyField;
$WA_mrtJoinRS = mysql_query($WA_Sql, $WA_connection) or die(mysql_error());
if (mysql_num_rows($WA_mrtJoinRS) > 0) {
while ($row_WA_mrtJoinRS = mysql_fetch_assoc($WA_mrtJoinRS)) {
$WA_PreSelect_RelationalTable_1[] = $row_WA_mrtJoinRS[$WA_joinedKeyField];
}
}
?>