PHP if()是否未按设计工作?
这是一个有点困惑为什么这不会工作。我可以做一些工作,但是有什么想法吗?它是将上传的CSV与数据库中的配置相匹配。仅返回前5列。其余的,用户指定的(应打印回显)不会显示 $csv\u循环时的列= 01 2 3 4 5 6 7 8 9 10 11 12 14 16 17 19 20 21 22 24 25 26 27 29 30 31 32 33 35 36 37 38 39 40 41 42 44 45 46 48 49 $getConfiguration[0]= 排列 ( [配置键]=>22 [配置客户端识别]=>105 [config_s_timestamp]=>137808000 [配置时间戳]=> [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]=> ) $csvRead[0] 排列 ( [0]=>数据日期 [1] =>代理识别 [2] =>客户端标识 [3] =>位置标识 [4] =>程序标识 [5] =>xx甚小孔径终端 [6] =>xx SWSAT [7] =>xx NSODS [8] =>xx SWDSAT ) 从查询返回 排列 ( [0]=>阵列 ( [密钥id]=>84 [已启用按键]=>1 [按键名称]=>xx SWDSAT [key_desc]=>xx CSAT有些不满意 ) )PHP if()是否未按设计工作?,php,mysql,Php,Mysql,这是一个有点困惑为什么这不会工作。我可以做一些工作,但是有什么想法吗?它是将上传的CSV与数据库中的配置相匹配。仅返回前5列。其余的,用户指定的(应打印回显)不会显示 $csv\u循环时的列= 01 2 3 4 5 6 7 8 9 10 11 12 14 16 17 19 20 21 22 24 25 26 27 29 30 31 32 33 35 36 37 38 39 40 41 42 44 45 46 48 49 $getConfiguration[0]= 排列 ( [配置键]=>22 [
//构建检查库
$checkArray=数组(“数据日期”、“代理标识”、“客户标识”、“位置标识”、“程序标识”);
$fileVerification=true;
$config_col=1;
//循环浏览50个可用列
while($config\u colwhile($csv\u col<5){
如果($csvRead[0][$csv\u col]==$checkArray[$csv\u col]){
$output.='-'.$csvRead[0][$csv\u col].'column verified';
如果只运行一次,如果您想连接use while,它将运行..直到结束。您的代码中有许多if
语句。哪一个语句没有按预期工作?请具体说明,并制作一个可复制的示例。我可以向您保证if
工作正常,问题是您的代码。var\u dump
ed t这些变量可以查看您所检查的内容实际上是您认为应该是$getConfiguration[0]
中的内容?@FluffyMittensofDeath:当这行代码“失败”时,$csv\u col
的值是多少?
// 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>";
// 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;
while($csv_col < 5){
if($csvRead[0][$csv_col] == $checkArray[$csv_col]){
$output .= '<div class="messageGood"> - '.$csvRead[0][$csv_col].' column verified.</div>';