Hi, all...
i made a table whith several multiple value fields, each field separated by comma, which i would like to convert into single rows. Now, on the add page - before record added - i'm using this and it works fine, it separates all values into appropriate rows, but as a last row it repeats the starting row with multiple values in the field which i would like to avoid...but wasn't able to do so. Can anyone help me with this
THANK YOU
global $conn;
$tempLength =0;
$user = $values["User"];
$client = $values["ClientInfo"];
$scope = $values["ScopeOFWork"];
$arr = explode(",",$values["RecievingCountry"]);
$arr2 = explode(",",$values["ContactPerson"]);
$arr3 = explode(",",$values["EstimatedFeesLocalCurrency"]);
$arr6 = explode(",",$values["ServiceRequired"]);
$arr5 = explode(",",$values["ActualFeesLocalCurrency"]);
$check1 = count($arr);
$check2 = count($arr2);
$check3 = count($arr3);
$check4=2;
$check5 = count($arr5);
$check6 = count($arr6);
if (($check1 == $check2) && ($check1 == $check3)&&($check1 == $check5)&&($check1 == $check6)&&!($check1>=2)){
return true;
}
else
{
(count($arr) <= count($arr2)) ? $tempLength = count($arr) : $tempLength = count($arr2);
if ($tempLength <=count($arr3)) $tempLength = count($arr3);
if ($tempLength <=count($arr5)) $tempLength = count($arr5);
if ($tempLength <=count($arr6)) $tempLength = count($arr6);
for ($i=0;$i<$tempLength;$i++)
{
$strInsert = "insert into RefferedWorkForm (RecievingCountry, ContactPerson, EstimatedFeesLocalCurrency, ActualFeesLocalCurrency, ServiceRequired, ClientInfo, ScopeOFWork, User) values ('".$arr[$i]."','".$arr2[$i]."','".$arr3[$i]."','".$arr5[$i]."', '".$arr6[$i]."', '$client', '$scope', '$user')";
db_exec($strInsert,$conn);
}
if ($tempLength = count($arr)){
for ($i=$tempLength;$i<count($arr2);$i++)
{
$strInsert = "insert into RefferedWorkForm (ContactPerson) values ('".$arr2[$i]."')";
db_exec($strInsert,$conn);
}
for ($i=$tempLength;$i<count($arr3);$i++)
{
$strInsert = "insert into RefferedWorkForm (EstimatedFeesLocalCurrency) values ('".$arr3[$i]."')";
db_exec($strInsert,$conn);
}
for ($i=$tempLength;$i<count($arr5);$i++)
{
$strInsert = "insert into RefferedWorkForm (ActualFeesLocalCurrency) values ('".$arr5[$i]."')";
db_exec($strInsert,$conn);
}
for ($i=$tempLength;$i<count($arr6);$i++)
{
$strInsert = "insert into RefferedWorkForm (ServiceRequired,ScopeOFWork,ClientInfo,User) values ('".$arr6[$i]."', '$scope', '$client', '$user')";
db_exec($strInsert,$conn);
}
}
if ($tempLength = count($arr2)){
for ($i=$tempLength;$i<count($arr);$i++)
{
$strInsert = "insert into RefferedWorkForm (ReceivingCountry) values ('".$arr[$i]."')";
db_exec($strInsert,$conn);
}
for ($i=$tempLength;$i<count($arr3);$i++)
{
$strInsert = "insert into RefferedWorkForm (EstimatedFeesLocalCurrency) values ('".$arr3[$i]."')";
db_exec($strInsert,$conn);
}
for ($i=$tempLength;$i<count($arr5);$i++)
{
$strInsert = "insert into RefferedWorkForm (ActualFeesLocalCurrency) values ('".$arr5[$i]."')";
db_exec($strInsert,$conn);
}
for ($i=$tempLength;$i<count($arr6);$i++)
{
$strInsert = "insert into RefferedWorkForm (ServiceRequired,ScopeOFWork,ClientInfo,User) values ('".$arr6[$i]."', '$scope', '$client', '$user')";
db_exec($strInsert,$conn);
}
}
if ($tempLength = count($arr3)){
for ($i=$tempLength;$i<count($arr);$i++)
{
$strInsert = "insert into RefferedWorkForm (ReceivingCountry) values ('".$arr[$i]."')";
db_exec($strInsert,$conn);
}
for ($i=$tempLength;$i<count($arr2);$i++)
{
$strInsert = "insert into RefferedWorkForm (ContactPerson) values ('".$arr2[$i]."')";
db_exec($strInsert,$conn);
}
for ($i=$tempLength;$i<count($arr5);$i++)
{
$strInsert = "insert into RefferedWorkForm (ActualFeesLocalCurrency) values ('".$arr5[$i]."')";
db_exec($strInsert,$conn);
}
for ($i=$tempLength;$i<count($arr6);$i++)
{
$strInsert = "insert into RefferedWorkForm (ServiceRequired,ScopeOFWork,ClientInfo,User) values ('".$arr6[$i]."', '$scope', '$client', '$user')";
db_exec($strInsert,$conn);
}
}
if ($tempLength = count($arr5)){
for ($i=$tempLength;$i<count($arr);$i++)
{
$strInsert = "insert into RefferedWorkForm (ReceivingCountry) values ('".$arr[$i]."')";
db_exec($strInsert,$conn);
}
for ($i=$tempLength;$i<count($arr3);$i++)
{
$strInsert = "insert into RefferedWorkForm (EstimatedFeesLocalCurrency) values ('".$arr3[$i]."')";
db_exec($strInsert,$conn);
}
for ($i=$tempLength;$i<count($arr2);$i++)
{
$strInsert = "insert into RefferedWorkForm (ContactPerson) values ('".$arr2[$i]."')";
db_exec($strInsert,$conn);
}
for ($i=$tempLength;$i<count($arr6);$i++)
{
$strInsert = "insert into RefferedWorkForm (ServiceRequired,ScopeOFWork,ClientInfo,User) values ('".$arr6[$i]."', '$scope', '$client', '$user')";
db_exec($strInsert,$conn);
}
}
if ($tempLength = count($arr6)){
for ($i=$tempLength;$i<count($arr);$i++)
{
$strInsert = "insert into RefferedWorkForm (ReceivingCountry) values ('".$arr[$i]."')";
db_exec($strInsert,$conn);
}
for ($i=$tempLength;$i<count($arr3);$i++)
{
$strInsert = "insert into RefferedWorkForm (EstimatedFeesLocalCurrency) values ('".$arr3[$i]."')";
db_exec($strInsert,$conn);
}
for ($i=$tempLength;$i<count($arr2);$i++)
{
$strInsert = "insert into RefferedWorkForm (ContactPerson) values ('".$arr2[$i]."')";
db_exec($strInsert,$conn);
}
for ($i=$tempLength;$i<count($arr5);$i++)
{
$strInsert = "insert into RefferedWorkForm (ActualFeesLocalCurrency,ScopeOFWork,ClientInfo,User) values ('".$arr5[$i]."', '$scope', '$client', '$user')";
db_exec($strInsert,$conn);
}
}
}
return true;
}