从逗号分隔的mysql中检索数据

时间:2016-07-06 02:29:28

标签: php mysql

我越想到这一点,我认为我的设计存在根本问题。我有一张表格。我有一个选择输入选项。用户最多可以从列表中选择四个项目。每个选项都有一个与之关联的数字。提交表单时,所选的每个选项的编号将一起添加,用逗号分隔并添加到数据库中的列。我无法控制他们选择选项的顺序。他们可以选择总共30个选项。因此,我最终在列中的4个数字,范围从1-30,而不是特定的顺序。在某些时候,用户将在另一个屏幕中选择一个选项,并且所有与该选项相关的信息应以表格形式显示。我正在努力从数据库中获取一个选项号。我从数据库中选择了带有选项编号的列,并使用逗号作为分隔符将其传递给explode(),但它没有返回任何内容。如果我对数据库列上的查询返回的$行执行var_dump,则可以看到已检索到所有信息。所以我很接近。这就是我如何爆炸返回的数据。

    var_dump(explode(',' , $rows['scat']));

更大的问题可能是,一旦我从数据库中获取信息,我将如何从中提取特定数字,因为它可能介于1到30之间,并且没有特定的顺序。

1 个答案:

答案 0 :(得分:-1)

您必须一步一步关注: -

将数据保存到数据库使用时: -

REM {Activities after saving document: Calculate the sum of completed HMRs and save in master document};
REM {Update each component entry of this machine
if component has not completed target hours, add current day's sum to it. };
REM {Calculate HMRs before and after current entry, send mail notification after each 500 hours, starting with 480 1st mail will be triggered on 480, 2nd on 980 and so on };
@If(@Command([FileSave]);
@Do(
varServer := @If(@ServerName = @UserName;"";@Name([CN];@ServerName));
lkpResult := @DbLookup("":"NOCACHE";varServer:@DbName[2];"vw_Daily_Logs";Machine_Line + "~" + Machine_ID;"Day_Run_Mileage");
shift_A_Run := @If(@Trim(@Text(Stop_HMR_A)) = "";0;Stop_HMR_A < Start_HMR_A;0;@Round(Stop_HMR_A - Start_HMR_A;0.1));
shift_B_Run := @If(@Trim(@Text(Stop_HMR_B)) = "";0;Stop_HMR_B < Start_HMR_B;0;@Round(Stop_HMR_B - Start_HMR_B;0.1));
shift_C_Run := @If(@Trim(@Text(Stop_HMR_C)) = "";0;Stop_HMR_C < Start_HMR_C;0;@Round(Stop_HMR_C - Start_HMR_C;0.1));
shift_A_Diesel := @If(Diesel_A = "";0;Diesel_A);
shift_B_Diesel := @If(Diesel_B = "";0;Diesel_B);
shift_C_Diesel := @If(Diesel_C = "";0;Diesel_C);
shift_A_Remarks := @If(Test_conducted_A = "Build/Part Fitment";"[PART FITMENT]:  "+ Test_Remarks_A;Test_conducted_A = "Breakdown/Hold";"[Breakdown/Hold]:  "+ Test_Remarks_A;Test_Remarks_A);
shift_B_Remarks := @If(Test_conducted_B = "Build/Part Fitment";"[PART FITMENT]:  "+ Test_Remarks_B;Test_conducted_B = "Breakdown/Hold";"[Breakdown/Hold]:  "+ Test_Remarks_B;Test_Remarks_B);
shift_C_Remarks := @If(Test_conducted_C = "Build/Part Fitment";"[PART FITMENT]:  "+ Test_Remarks_C;Test_conducted_C = "Breakdown/Hold";"[Breakdown/Hold]:  "+ Test_Remarks_C;Test_Remarks_C);
strRemarks := @If(@Trim(@Implode(Remarks_A)) = "";"";@Trim(@Implode(Remarks_A)));
strRemarks := strRemarks + @If(@Trim(@Implode(Remarks_B)) = "";"";@NewLine + @Trim(@Implode(Remarks_B)));
strRemarks := strRemarks + @If(@Trim(@Implode(Remarks_C)) = "";"";@NewLine + @Trim(@Implode(Remarks_C)));
strRemarks := @If(strRemarks = "";"-";strRemarks);
strRemarks := @ReplaceSubstring(strRemarks;",";".");
shift_A_Operator := @If(@Trim(Operator_A) = "";"-";Operator_A);
shift_B_Operator := @If(@Trim(Operator_B) = "";"-";Operator_B);
shift_C_Operator := @If(@Trim(Operator_C) = "";"-";Operator_C);
shift_A_Test := @If(@Trim(Test_conducted_A) = "";"-";Test_conducted_A);
shift_B_Test := @If(@Trim(Test_conducted_B) = "";"-";Test_conducted_B);
shift_C_Test := @If(@Trim(Test_conducted_C) = "";"-";Test_conducted_C);
meter_Change_HMR_Reading := Meter_Changed_At_HMR;
@If(@GetDocField(ParentUNID;"DateList")[1] = "-";
@Do(
@SetDocField(ParentUNID;"Total_Vehicle_Hours";Cumulative_Vehicle_Hours);
 varSerialNoList := "1";
Milage_Plan_Tmp := Milage_Plan;
varPlannedHrsList := @Text(Cumulative_Vehicle_Reading_Plan + Milage_Plan_Tmp);
plannedHRSCumulative := Cumulative_Vehicle_Reading_Plan + Milage_Plan_Tmp;
tmpTargetHMR := Target_HMR;
varActualHrsList := @Text(HMR_Start_Reading + shift_A_Run + shift_B_Run + shift_C_Run);
varHMR_A := @Text(shift_A_Run);
varHMR_B := @Text(shift_B_Run);
varHMR_C := @Text(shift_C_Run);
varHMR_Total := @Text(shift_A_Run + shift_B_Run + shift_C_Run);
varDiesel_A := @Text(shift_A_Diesel);
varDiesel_B := @Text(shift_B_Diesel);
varDiesel_C := @Text(shift_C_Diesel);
varDiesel_Total := @Text(shift_A_Diesel + shift_B_Diesel + shift_C_Diesel);
varRemarksList := @If(strRemarks = "";"-";strRemarks);
varRemarksList_A := @If(shift_A_Remarks = "";"-";shift_A_Remarks);
varRemarksList_B := @If(shift_B_Remarks = "";"-";shift_B_Remarks);
varRemarksList_C := @If(shift_C_Remarks = "";"-";shift_C_Remarks);
varOperatorList_A := @If(shift_A_Operator = "";"-";shift_A_Operator);
varOperatorList_B := @If(shift_B_Operator = "";"-";shift_B_Operator);
varOperatorList_C := @If(shift_C_Operator = "";"-";shift_C_Operator);
varTestList_A := @If(shift_A_Test = "";"-";shift_A_Test);
varTestList_B := @If(shift_B_Test = "";"-";shift_B_Test);
varTestList_C := @If(shift_C_Test = "";"-";shift_C_Test);
daysToRun := @GetDocField(ParentUNID;"DaysToRun");
targetHrs := @GetDocField(ParentUNID;"Target_HMR");
tmpDate := @Date(Log_Date);
datesList := @Text(tmpDate);
@For(tmpKtr := 2; tmpKtr <= daysToRun;tmpKtr := tmpKtr + 1;@Do(
tmpDate := @If(@Weekday(@Adjust(tmpDate;0;0;1;0;0;0)) =    1; @Adjust(tmpDate;0;0;2;0;0;0);@Adjust(tmpDate;0;0;1;0;0;0));
datesList := datesList : @Text(tmpDate);
varSerialNoList := varSerialNoList : @Text(tmpKtr);
plannedHRSCumulative := @If(plannedHRSCumulative + Milage_Plan_Tmp > Scheduled_Closing_HMR;Scheduled_Closing_HMR;plannedHRSCumulative + Milage_Plan_Tmp);
varPlannedHrsList := varPlannedHrsList : @Text(plannedHRSCumulative);
varActualHrsList := varActualHrsList  : "-";
varHMR_A := varHMR_A : "-";
varHMR_B := varHMR_B : "-";
varHMR_C := varHMR_C : "-";
varHMR_Total := varHMR_Total : "-";
varDiesel_A := varDiesel_A : "-";
varDiesel_B := varDiesel_B : "-";
varDiesel_C := varDiesel_C : "-";
varDiesel_Total := varDiesel_Total : "-";
varRemarksList := varRemarksList : "-";
varRemarksList_A := varRemarksList_A : "-";
varRemarksList_B := varRemarksList_B : "-";
varRemarksList_C := varRemarksList_C : "-";
varOperatorList_A := varOperatorList_A : "-";
varOperatorList_B := varOperatorList_B : "-";
varOperatorList_C := varOperatorList_C : "-";
varTestList_A := varTestList_A : "-";
varTestList_B := varTestList_B : "-";
varTestList_C := varTestList_C : "-"
));
@SetDocField(ParentUNID;"Total_Vehicle_Hours";Cumulative_Vehicle_Hours);
@SetDocField(ParentUNID;"SerialNoList";varSerialNoList);
@SetDocField(ParentUNID;"DateList";datesList);
@SetDocField(ParentUNID;"PlannedHrsList";varPlannedHrsList);
@SetDocField(ParentUNID;"ActualHrsList";varActualHrsList);
@SetDocField(ParentUNID;"Machine_Run_Time_A";varHMR_A);
@SetDocField(ParentUNID;"Machine_Run_Time_B";varHMR_B);
@SetDocField(ParentUNID;"Machine_Run_Time_C";varHMR_C);
@SetDocField(ParentUNID;"Machine_Run_Time_Total";varHMR_Total);
@SetDocField(ParentUNID;"DieselConsumedListShiftA";varDiesel_A);
@SetDocField(ParentUNID;"DieselConsumedListShiftB";varDiesel_B);
@SetDocField(ParentUNID;"DieselConsumedListShiftC";varDiesel_C);
@SetDocField(ParentUNID;"DieselConsumedListTotal";varDiesel_Total);
@SetDocField(ParentUNID;"RemarksList";varRemarksList);
@SetDocField(ParentUNID;"RemarksListA";varRemarksList_A);
@SetDocField(ParentUNID;"RemarksListB";varRemarksList_B);
@SetDocField(ParentUNID;"RemarksListC";varRemarksList_C);
@SetDocField(ParentUNID;"OperatorListA";varOperatorList_A);
@SetDocField(ParentUNID;"OperatorListB";varOperatorList_B);
@SetDocField(ParentUNID;"OperatorListC";varOperatorList_C);
@SetDocField(ParentUNID;"TestListA";varTestList_A);
@SetDocField(ParentUNID;"TestListB";varTestList_B);
@SetDocField(ParentUNID;"TestListC";varTestList_C);
@SetDocField(ParentUNID;"Meter_Changed_At_HMR";meter_Change_HMR_Reading)
);
@Do(
varSeqNoList := @GetDocField(ParentUNID;"SerialNoList")[1];
varDateList :=  @GetDocField(ParentUNID;"DateList")[1];
varPlannedHrsList := @GetDocField(ParentUNID;"PlannedHrsList")[1];
varActualHrsList := @GetDocField(ParentUNID;"ActualHrsList")[1];
varHMR_A := @GetDocField(ParentUNID;"Machine_Run_Time_A")[1];
varHMR_B := @GetDocField(ParentUNID;"Machine_Run_Time_B")[1];
varHMR_C := @GetDocField(ParentUNID;"Machine_Run_Time_C")[1];
varHMR_Total := @GetDocField(ParentUNID;"Machine_Run_Time_Total")[1];
varDiesel_A := @GetDocField(ParentUNID;"DieselConsumedListShiftA")[1];
varDiesel_B := @GetDocField(ParentUNID;"DieselConsumedListShiftB")[1];
varDiesel_C := @GetDocField(ParentUNID;"DieselConsumedListShiftC")[1];
varDiesel_Total := @GetDocField(ParentUNID;"DieselConsumedListTotal")[1];
varRemarksList := @GetDocField(ParentUNID;"RemarksList")[1];
varRemarksList_A := @GetDocField(ParentUNID;"RemarksListA")[1];
varRemarksList_B := @GetDocField(ParentUNID;"RemarksListB")[1];
varRemarksList_C := @GetDocField(ParentUNID;"RemarksListC")[1];
varOperatorList_A := @GetDocField(ParentUNID;"OperatorListA")[1];
varOperatorList_B := @GetDocField(ParentUNID;"OperatorListB")[1];
varOperatorList_C := @GetDocField(ParentUNID;"OperatorListC")[1];
varTestList_A := @GetDocField(ParentUNID;"TestListA")[1];
varTestList_B := @GetDocField(ParentUNID;"TestListB")[1];
varTestList_C := @GetDocField(ParentUNID;"TestListC")[1];
varDelayCount := 0;
@For(itemKtr := 2; itemKtr <= @Elements(@GetDocField(ParentUNID;"DateList")); itemKtr := itemKtr + 1;
varSeqNoList := varSeqNoList : @GetDocField(ParentUNID;"SerialNoList")[itemKtr];
varDateList := varDateList : @GetDocField(ParentUNID;"DateList")[itemKtr];
varPlannedHrsList := varPlannedHrsList : @GetDocField(ParentUNID;"PlannedHrsList")[itemKtr];
@If(@Text(@Date(Log_Date)) = @GetDocField(ParentUNID;"DateList")[itemKtr];
@Do(
varActualHrsList := varActualHrsList : @Text(HMR_Start_Reading + shift_A_Run + shift_B_Run + shift_C_Run);
varHMR_A := varHMR_A : @Text(shift_A_Run);
varHMR_B := varHMR_B : @Text(shift_B_Run);
varHMR_C := varHMR_C : @Text(shift_C_Run);
varHMR_Total := varHMR_Total : @Text(shift_A_Run + shift_B_Run + shift_C_Run);
varDiesel_A := varDiesel_A : @Text(shift_A_Diesel);
varDiesel_B := varDiesel_B : @Text(shift_B_Diesel);
varDiesel_C := varDiesel_C : @Text(shift_C_Diesel);
varDiesel_Total := varDiesel_Total : @Text(shift_A_Diesel + shift_B_Diesel + shift_C_Diesel);
varRemarksList := varRemarksList : @If(strRemarks = "";"-";strRemarks);
varRemarksList_A := varRemarksList_A : @If(shift_A_Remarks = "";"-";shift_A_Remarks);
varRemarksList_B := varRemarksList_B : @If(shift_B_Remarks = "";"-";shift_B_Remarks);
varRemarksList_C := varRemarksList_C : @If(shift_C_Remarks = "";"-";shift_C_Remarks);
varOperatorList_A := varOperatorList_A : @If(shift_A_Operator = "";"-";shift_A_Operator);
varOperatorList_B := varOperatorList_B : @If(shift_B_Operator = "";"-";shift_B_Operator);
varOperatorList_C := varOperatorList_C : @If(shift_C_Operator = "";"-";shift_C_Operator);
varTestList_A := varTestList_A : @If(shift_A_Test = "";"-";shift_A_Test);
varTestList_B := varTestList_B : @If(shift_B_Test = "";"-";shift_B_Test);
varTestList_C := varTestList_C : @If(shift_C_Test = "";"-";shift_C_Test)
);
@Date(Log_Date) > @TextToTime(@GetDocField(ParentUNID;"DateList")[itemKtr]) & @GetDocField(ParentUNID;"ActualHrsList")[itemKtr] = "-";
@Do(
varDelayCount := varDelayCount + 1;
varActualHrsList := varActualHrsList : varActualHrsList[itemKtr - 1];
varHMR_A := varHMR_A : "0";
varHMR_B := varHMR_B : "0";
varHMR_C := varHMR_C : "0";
varHMR_Total := varHMR_Total : "0";
varDiesel_A := varDiesel_A : "0";
varDiesel_B := varDiesel_B : "0";
varDiesel_C := varDiesel_C : "0";
varDiesel_Total := varDiesel_Total : "0";
varRemarksList := varRemarksList : "-";
varRemarksList_A := varRemarksList_A : "-";
varRemarksList_B := varRemarksList_B : "-";
varRemarksList_C := varRemarksList_C : "-";
varOperatorList_A := varOperatorList_A : "-";
varOperatorList_B := varOperatorList_B : "-";
varOperatorList_C := varOperatorList_C : "-";
varTestList_A := varTestList_A : "-";
varTestList_B := varTestList_B : "-";
varTestList_C := varTestList_C : "-"
);
@Do(
varActualHrsList := varActualHrsList : @GetDocField(ParentUNID;"ActualHrsList")[itemKtr];
varHMR_A := varHMR_A : @GetDocField(ParentUNID;"Machine_Run_Time_A")[itemKtr];
varHMR_B := varHMR_B : @GetDocField(ParentUNID;"Machine_Run_Time_B")[itemKtr];
varHMR_C := varHMR_C : @GetDocField(ParentUNID;"Machine_Run_Time_C")[itemKtr];
varHMR_Total := varHMR_Total : @GetDocField(ParentUNID;"Machine_Run_Time_Total")[itemKtr];
varDiesel_A := varDiesel_A : @GetDocField(ParentUNID;"DieselConsumedListShiftA")[itemKtr];
varDiesel_B := varDiesel_B : @GetDocField(ParentUNID;"DieselConsumedListShiftB")[itemKtr];
varDiesel_C := varDiesel_C : @GetDocField(ParentUNID;"DieselConsumedListShiftC")[itemKtr];
varDiesel_Total := varDiesel_Total : @GetDocField(ParentUNID;"DieselConsumedListTotal")[itemKtr];
varRemarksList := varRemarksList : @GetDocField(ParentUNID;"RemarksList")[itemKtr];
varRemarksList_A := varRemarksList_A : @GetDocField(ParentUNID;"RemarksListA")[itemKtr];
varRemarksList_B := varRemarksList_B : @GetDocField(ParentUNID;"RemarksListB")[itemKtr];
varRemarksList_C := varRemarksList_C : @GetDocField(ParentUNID;"RemarksListC")[itemKtr];
varOperatorList_A := varOperatorList_A : @GetDocField(ParentUNID;"OperatorListA")[itemKtr];
varOperatorList_B := varOperatorList_B : @GetDocField(ParentUNID;"OperatorListB")[itemKtr];
varOperatorList_C := varOperatorList_C : @GetDocField(ParentUNID;"OperatorListC")[itemKtr];
varTestList_A := varTestList_A : @GetDocField(ParentUNID;"TestListA")[itemKtr];
varTestList_B := varTestList_B : @GetDocField(ParentUNID;"TestListB")[itemKtr];
varTestList_C := varTestList_C : @GetDocField(ParentUNID;"TestListC")[itemKtr]
)
)
);
varExtendedDate := @TextToTime(varDateList[@Elements(varDateList)]);
@For(delayKtr := 1; delayKtr <= varDelayCount; delayKtr := delayKtr + 1;
@Do(
varExtendedDate := @Adjust(varExtendedDate;0;0;1;0;0;0);
varExtendedDate := @If(@Weekday(varExtendedDate) = 1;@Adjust(varExtendedDate;0;0;1;0;0;0);varExtendedDate);
varSeqNoList := varSeqNoList : @Text(@Elements(varSeqNoList) + 1);
varDateList := varDateList : @Text(varExtendedDate);
varPlannedHrsList := varPlannedHrsList : "-";
varActualHrsList := varActualHrsList : "-";
varHMR_A := varHMR_A : "-";
varHMR_B := varHMR_B : "-";
varHMR_C := varHMR_C : "-";
varHMR_Total := varHMR_Total : "-";
varDiesel_A := varDiesel_A : "-";
varDiesel_B := varDiesel_B : "-";
varDiesel_C := varDiesel_C : "-";
varDiesel_Total := varDiesel_Total : "-";
varRemarksList := varRemarksList : "-";
varRemarksList_A := varRemarksList_A : "-";
varRemarksList_B := varRemarksList_B : "-";
varRemarksList_C := varRemarksList_C : "-";
varOperatorList_A := varOperatorList_A : "-";
varOperatorList_B :=varOperatorList_B : "-";
varOperatorList_C := varOperatorList_C : "-";
varTestList_A := varTestList_A : "-";
varTestList_B :=varTestList_B : "-";
varTestList_C := varTestList_C : "-"
)
);
@SetDocField(ParentUNID;"Total_Vehicle_Hours";@Sum(lkpResult));
delayHrsTotal := @If(@GetDocField(ParentUNID;"DelayHrs") = "";0;@TextToNumber(@GetDocField(ParentUNID;"DelayHrs")));
delayHrsTotal := delayHrsTotal + varDelayCount*Milage_Plan;
@SetDocField(ParentUNID;"DelayHrs";@Text(delayHrsTotal));
@SetDocField(ParentUNID;"SerialNoList";varSeqNoList);
@SetDocField(ParentUNID;"DateList";varDateList);
@SetDocField(ParentUNID;"PlannedHrsList";varPlannedHrsList);
@SetDocField(ParentUNID;"ActualHrsList";varActualHrsList);
@SetDocField(ParentUNID;"Machine_Run_Time_A";varHMR_A);
@SetDocField(ParentUNID;"Machine_Run_Time_B";varHMR_B);
@SetDocField(ParentUNID;"Machine_Run_Time_C";varHMR_C);
@SetDocField(ParentUNID;"Machine_Run_Time_Total";varHMR_Total);
@SetDocField(ParentUNID;"DieselConsumedListShiftA";varDiesel_A);
@SetDocField(ParentUNID;"DieselConsumedListShiftB";varDiesel_B);
@SetDocField(ParentUNID;"DieselConsumedListShiftC";varDiesel_C);
@SetDocField(ParentUNID;"DieselConsumedListTotal";varDiesel_Total);
@SetDocField(ParentUNID;"RemarksList";varRemarksList);
@SetDocField(ParentUNID;"RemarksListA";varRemarksList_A);
@SetDocField(ParentUNID;"RemarksListB";varRemarksList_B);
@SetDocField(ParentUNID;"RemarksListC";varRemarksList_C);
@SetDocField(ParentUNID;"OperatorListA";varOperatorList_A);
@SetDocField(ParentUNID;"OperatorListB";varOperatorList_B);
@SetDocField(ParentUNID;"OperatorListC";varOperatorList_C);
@SetDocField(ParentUNID;"TestListA";varTestList_A);
@SetDocField(ParentUNID;"TestListB";varTestList_B);
@SetDocField(ParentUNID;"TestListC";varTestList_C);
@SetDocField(ParentUNID;"Meter_Changed_At_HMR";meter_Change_HMR_Reading)
)
);
@For(tmpKtr := 1; tmpKtr <= @Elements(componentsUNID);tmpKtr := tmpKtr + 1;
@Do(
totalHRS := @TextToNumber(@GetDocField(componentsUNID[tmpKtr];"Total_Component_Hours"));
targetRun := @TextToNumber(@GetDocField(componentsUNID[tmpKtr];"Component_Target_HMR"));
FailedFlag := @GetDocField(componentsUNID[tmpKtr];"FailedFlag");
fitmentDate := @GetDocField(componentsUNID[tmpKtr];"Fitment_Date");
component_Starting_HMR := @GetDocField(componentsUNID[tmpKtr];"Starting_HMR");
@If(targetRun > totalHRS & fitmentDate <= Log_Date & FailedFlag != "Yes";
@Do(
logDates := @Implode(@GetDocField(componentsUNID[tmpKtr];"Log_Dates");",");
shift1Runs := @Implode(@GetDocField(componentsUNID[tmpKtr];"Shift1_Runs");",");
shift2Runs := @Implode(@GetDocField(componentsUNID[tmpKtr];"Shift2_Runs");",");
shift3Runs := @Implode(@GetDocField(componentsUNID[tmpKtr];"Shift3_Runs");",");
shift1Diesel := @Implode(@GetDocField(componentsUNID[tmpKtr];"Shift1_Diesel");",");
shift2Diesel := @Implode(@GetDocField(componentsUNID[tmpKtr];"Shift2_Diesel");",");
shift3Diesel := @Implode(@GetDocField(componentsUNID[tmpKtr];"Shift3_Diesel");",");
shift1Remarks := @Implode(@GetDocField(componentsUNID[tmpKtr];"RemarksA");",");
shift2Remarks := @Implode(@GetDocField(componentsUNID[tmpKtr];"RemarksB");",");
shift3Remarks := @Implode(@GetDocField(componentsUNID[tmpKtr];"RemarksC");",");
plannedHrsListCompleted := @Implode(@GetDocField(componentsUNID[tmpKtr];"PlannedHrsListCompleted");",");
actualHrsListCompleted := @Implode(@GetDocField(componentsUNID[tmpKtr];"ActualHrsListCompleted");",");
hrsInShift1 := 0;
hrsInShift2 := 0;
hrsInShift3 := 0;
@If(@Trim(shift1Runs) != "";
@Do(
hrsInShift1 := shift_A_Run;
hrsInShift2 := shift_B_Run;
hrsInShift3 := shift_C_Run;
logDates := @Explode(logDates + "," + @Text(@Date(@GetField("Log_Date")));",");
shift1Runs := @Explode(shift1Runs + "," + @Text(shift_A_Run);",");
shift2Runs := @Explode(shift2Runs + "," + @Text(shift_B_Run);",");
shift3Runs := @Explode(shift3Runs + "," + @Text(shift_C_Run);",");
shift1Diesel := @Explode(shift1Diesel + "," + @If(@Text(Diesel_A) = "";"0";@Text(Diesel_A));",");
shift2Diesel := @Explode(shift2Diesel + "," + @If(@Text(Diesel_B) = "";"0";@Text(Diesel_B));",");
shift3Diesel := @Explode(shift3Diesel + "," + @If(@Text(Diesel_C) = "";"0";@Text(Diesel_C));",");
shift1Remarks := @Explode(shift1Remarks + "," + @If(@Trim(Remarks_A) = "";"-";@Text(Remarks_A));",");
shift2Remarks := @Explode(shift2Remarks + "," + @If(@Trim(Remarks_B) = "";"-";@Text(Remarks_B));",");
shift3Remarks := @Explode(shift3Remarks + "," + @If(@Trim(Remarks_C) = "";"-";@Text(Remarks_C));",");
plannedHrsListCompleted := @Explode(plannedHrsListCompleted + "," + @Text(Cumulative_Vehicle_Reading_Plan + Milage_Plan);",");
actualHrsListCompleted := @Explode(actualHrsListCompleted + "," + @Text(HMR_End_Reading);",")
);
@Do(
logDates := @Text(@Date(@GetField("Log_Date")));
@If(HMR_Start_Reading + shift_A_Run >= component_Starting_HMR;
@Do(
hrsInShift1 := HMR_Start_Reading + shift_A_Run - component_Starting_HMR;
shift1Runs := @Text(hrsInShift1);
shift1Diesel := @If(@Text(Diesel_A) = "";"0";@Text(Diesel_A));
shift1Remarks := @If(@Trim(@Text(Remarks_A)) = "";"-";@Text(Remarks_A))
);
@Do(
shift1Runs := "0";
shift1Diesel := "0";
shift1Remarks := "-"
)
);

@If(HMR_Start_Reading + shift_A_Run + shift_B_Run >= component_Starting_HMR;
@Do(
hrsInShift2 := HMR_Start_Reading + shift_A_Run + shift_B_Run - component_Starting_HMR - hrsInShift1;
shift2Runs := @Text(hrsInShift2);
shift2Diesel := @If(@Text(Diesel_B) = "";"0";@Text(Diesel_B));
shift2Remarks := @If(@Trim(@Text(Remarks_B)) = "";"-";@Text(Remarks_B))
);
@Do(
shift2Runs := "0";
shift2Diesel := "0";
shift2Remarks := "-"
)
);
@If(HMR_Start_Reading + shift_A_Run + shift_B_Run + shift_C_Run >= component_Starting_HMR;
@Do(
hrsInShift3 := HMR_Start_Reading + shift_A_Run + shift_B_Run + shift_C_Run - component_Starting_HMR - hrsInShift1 - hrsInShift2;
shift3Runs := @Text(hrsInShift3);
shift3Diesel := @If(@Text(Diesel_C) = "";"0";@Text(Diesel_C));
shift3Remarks := @If(@Trim(@Text(Remarks_C)) = "";"-";@Text(Remarks_C))
);
@Do(
shift3Runs := "0";
shift3Diesel := "0";
shift3Remarks := "-"
)
);
plannedHrsListCompleted := @Text(Cumulative_Vehicle_Reading_Plan + Milage_Plan);
actualHrsListCompleted := @Text(HMR_End_Reading)
)
);
@SetDocField(componentsUNID[tmpKtr];"Total_Component_Hours";@Text(totalHRS + hrsInShift1 + hrsInShift2 + hrsInShift3));
@SetDocField(componentsUNID[tmpKtr];"Log_Dates";logDates);
@SetDocField(componentsUNID[tmpKtr];"Shift1_Runs";shift1Runs);
@SetDocField(componentsUNID[tmpKtr];"Shift2_Runs";shift2Runs);
@SetDocField(componentsUNID[tmpKtr];"Shift3_Runs";shift3Runs);
@SetDocField(componentsUNID[tmpKtr];"Shift1_Diesel";shift1Diesel);
@SetDocField(componentsUNID[tmpKtr];"Shift2_Diesel";shift2Diesel);
@SetDocField(componentsUNID[tmpKtr];"Shift3_Diesel";shift3Diesel);
@SetDocField(componentsUNID[tmpKtr];"RemarksA";shift1Remarks);
@SetDocField(componentsUNID[tmpKtr];"RemarksB";shift2Remarks);
@SetDocField(componentsUNID[tmpKtr];"RemarksC";shift3Remarks);
@SetDocField(componentsUNID[tmpKtr];"PlannedHrsListCompleted";plannedHrsListCompleted);
@SetDocField(componentsUNID[tmpKtr];"ActualHrsListCompleted";actualHrsListCompleted)
);
""
)
)
);
varTotalHMR_Before := Cumulative_Vehicle_Hours - Day_Run_Mileage;
varTotalHMR_After := Cumulative_Vehicle_Hours;
varServiceDueHrs := @GetDocField(ParentUNID;"Service_Alert_At_HMRs");
varSendMailFlag := 0;
@For(itemsKtr := 1; itemsKtr <= @Elements(varServiceDueHrs) & varSendMailFlag = 0;itemsKtr := itemsKtr + 1;
@Do(
currValue := @TextToNumber(varServiceDueHrs[itemsKtr]);
@If(currValue <= 20 & varTotalHMR_Before = 0;
varSendMailFlag := 1;
@Modulo(varTotalHMR_Before;currValue) < (currValue - 20) &     @Modulo(varTotalHMR_After;currValue) >= (currValue - 20);
varSendMailFlag := 1;
""
)
)
);
@If(varSendMailFlag = 1;
@Do(
varSendTo := T_And_D_Managers : T_And_D_Engineers;
varSubject := "[Daily Log System]: Machine Due For Service";
varBody := "Service is due for machine:: " + Machine_ID;
@MailSend(varSendTo;"";"";varSubject;"";varBody;0);
@Prompt([Ok];"Notification";"Notificaton `about` Service")
);
""
)
);"")

如果要检索数据,请使用此查询: -

$qry = "insert into registervendors (scat) values ('".implode(",", $_POST['scat'])."')";

获得结果后使用: -

$qry = "SELECT * FROM registervendors WHERE state='".$state."' AND FIND_IN_SET(".$scat.", scat) ORDER BY busname ASC";

这里$ catIds有1到30之间的类别列表。现在你需要在其中搜索10,所以使用: -

$catIDS = explode(",", $resultROw[$key]['scat']);