これは、なぜこれが機能しないのかについて少し混乱しています。回避策はありますが、何かアイデアはありますか?アップロードされた CSV をデータベースの構成に一致させるためです。最初の 5 列のみを返します。残りのユーザー指定のもの (Echo を出力する必要があります) は表示されません。
ループ中の $csv_col = 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 4 2 4 4 4 45 46 47 48 49
$getConfiguration[0] =
配列 ( [config_key] => 22 [config_client_ident] => 105 [config_s_timestamp] => 1378008000 [config_e_timestamp] => [config_kpi_1] => 81 [config_kpi_2] => 82 [config_kpi_3] => 83 [config_kpi_4] => 84 [ config_kpi_5] => [config_kpi_6] => [config_kpi_7] => [config_kpi_8] => [config_kpi_9] => [config_kpi_10] => [config_kpi_11] => [config_kpi_12] => [config_kpi_13] => [config_kpi_14] => [ config_kpi_15] => [config_kpi_16] => [config_kpi_17] => [config_kpi_18] => [config_kpi_19] => [config_kpi_20] => [config_kpi_21] => [config_kpi_22] => [config_kpi_23] => [config_kpi_24] =>[config_kpi_25] => [config_kpi_26] => [config_kpi_27] => [config_kpi_28] => [config_kpi_29] => [config_kpi_30] => [config_kpi_31] => [config_kpi_32] => [config_kpi_33] => [config_kpi_34] => [config_kpi_35] => [config_kpi_36] => [config_kpi_37] => [config_kpi_38] => [config_kpi_39] => [config_kpi_40] => [config_kpi_41] => [config_kpi_42] => [config_kpi_43] => [config_kpi_44] => [config_kpi_45] => [config_kpi_46] => [config_kpi_47] => [config_kpi_48] => [config_kpi_49] => [config_kpi_50] => )[config_kpi_28] => [config_kpi_29] => [config_kpi_30] => [config_kpi_31] => [config_kpi_32] => [config_kpi_33] => [config_kpi_34] => [config_kpi_35] => [config_kpi_36] => [config_kpi_37] => [config_kpi_38] => [config_kpi_39] => [config_kpi_40] => [config_kpi_41] => [config_kpi_42] => [config_kpi_43] => [config_kpi_44] => [config_kpi_45] => [config_kpi_46] => [config_kpi_47] => [config_kpi_48] => [config_kpi_49] => [config_kpi_50] => )[config_kpi_28] => [config_kpi_29] => [config_kpi_30] => [config_kpi_31] => [config_kpi_32] => [config_kpi_33] => [config_kpi_34] => [config_kpi_35] => [config_kpi_36] => [config_kpi_37] => [config_kpi_38] => [config_kpi_39] => [config_kpi_40] => [config_kpi_41] => [config_kpi_42] => [config_kpi_43] => [config_kpi_44] => [config_kpi_45] => [config_kpi_46] => [config_kpi_47] => [config_kpi_48] => [config_kpi_49] => [config_kpi_50] => )[config_kpi_35] => [config_kpi_36] => [config_kpi_37] => [config_kpi_38] => [config_kpi_39] => [config_kpi_40] => [config_kpi_41] => [config_kpi_42] => [config_kpi_43] => [config_kpi_44] => [config_kpi_45] => [config_kpi_46] => [config_kpi_47] => [config_kpi_48] => [config_kpi_49] => [config_kpi_50] => )[config_kpi_35] => [config_kpi_36] => [config_kpi_37] => [config_kpi_38] => [config_kpi_39] => [config_kpi_40] => [config_kpi_41] => [config_kpi_42] => [config_kpi_43] => [config_kpi_44] => [config_kpi_45] => [config_kpi_46] => [config_kpi_47] => [config_kpi_48] => [config_kpi_49] => [config_kpi_50] => )[config_kpi_48] => [config_kpi_49] => [config_kpi_50] => )[config_kpi_48] => [config_kpi_49] => [config_kpi_50] => )
$csvRead[0]
配列 ( [0] => データ日付 [1] => エージェント ID [2] => クライアント ID [3] => ロケーション ID [4] => プログラム ID [5] => xx VSAT [6] => xx SWSAT [7] => xx NSODS [8] => xx SWDSAT )
クエリから返されました
配列 ( [0] => 配列 ( [key_id] => 84 [key_enabled] => 1 [key_name] => xx SWDSAT [key_desc] => xx CSAT やや不満)
)
// Build the check arary
$checkArray = array("Data Date", "Agent IDENT", "Client IDENT", "Location IDENT", "Program IDENT");
$fileVerification = true;
$config_col = 1;
// Loop through the 50 available columns
while($config_col <= 50){
$csv_col = $config_col - 1;
print $csv_col . " ";
// Make sure something is in those columns
if($getConfiguration[0]['config_kpi_'.$config_col] != ''){
// There is, now lets query and get those names.
$getNamesQuery[] = "SELECT * FROM kpi_keys WHERE key_id=".$getConfiguration[0]['config_kpi_'.$config_col];
$getNamesResult = dbInsert($getNamesQuery);
// Compare the first 5 columns
if($csv_col < 5){
if($csvRead[0][$csv_col] == $checkArray[$csv_col]){
$output .= '<div class="messageGood"> - '.$csvRead[0][$csv_col].' column verified.</div>';
} else {
$output .= '<div class="messageBad"> - Column "'.$csvRead[0][$csv_col].'" did not match "'.$checkArray[$csv_col].'" in the current configuration.</div>';
$fileVerification = false;
}
} else {
// Now lets compare the customizable columns. We're going to do names and ID's to make sure.
print "Echo";
}
$getNamesQuery = null;
}
$config_col++;
}
// Now we check the information
print "<pre>";
print_r($getConfiguration[0]);
print_r($csvRead[0]);
print_r($getNamesResult);
print "</pre>";
回答 (ありがとう Wrikken)
// Loop through the 50 available columns
while($config_col <= 50){
$csv_col = $config_col - 1;
$partOne = '';
$partTwo = '';
// Make sure something is in those columns
// Compare the first 5 columns
if($csv_col < 5){
if($csvRead[0][$csv_col] == $checkArray[$csv_col]){
$partOne .= '<div class="messageGood"> - '.$csvRead[0][$csv_col].' column verified.</div>';
} else {
$partOne .= '<div class="messageBad"> - Column "'.$csvRead[0][$csv_col].'" did not match "'.$checkArray[$csv_col].'" in the current configuration.</div>';
$fileVerification = false;
}
}
if($getConfiguration[0]['config_kpi_'.$config_col] != ''){
print $csv_col . " ";
// There is, now lets query and get those names.
$getNamesQuery[] = "SELECT * FROM kpi_keys WHERE key_id=".$getConfiguration[0]['config_kpi_'.$config_col];
$getNamesResult = dbInsert($getNamesQuery);
// Now lets compare the customizable columns. We're going to do names and ID's to make sure.
$partTwo = "Comparison";
$getNamesQuery = null;
}
$config_col++;
}
$output .= $partOne . $partTwo;