$fields_arr = "SHOW FIELDS FROM 'payslip' WHERE FIELD NOT IN ('ID','Tax_Number','Employee_Number','Payslip_Number','Salary','Bonus',' Housing_Allowance','House1','Transport_Allowance','Travel_Allowance','Vehicle_Allowance',' Vehicle1','Cellphone_Allowance',' Entertainment_Allowance',' Company_Car',' Medical_Allowance','DSocial_Security',' DHousing_Allowance','DCompany_Car','DContributions','Other_Deductions','DVehicle_Allowance','Other_Allowance','Total_Income','Taxable_Income','Tax_Payable','Overtime','Overtime_Hours','Payday','Pension','Provident_Fund','Retirement_Annuity','Study_Policy','Month','Year','Company')";
$result3 = mysqli_query($conn, $fields_arr);
$fields = implode(',',$result3);
错误来自上面的代码,因为我没有传递数组但是另一种形式的数据类型对问题有任何帮助吗?我得到的错误是&#34; implode():传递的参数无效&#34; < / p>
$dql = "SELECT $fields FROM $tb2_name WHERE Month='$month' AND Year='$year' AND Employee_Number='$user' ";
答案 0 :(得分:1)
您必须首先使用例如mysqli_fetch_assoc
获取数据:
$fields_arr = "SHOW FIELDS FROM 'payslip' WHERE FIELD NOT IN ('ID','Tax_Number','Employee_Number','Payslip_Number','Salary','Bonus',' Housing_Allowance','House1','Transport_Allowance','Travel_Allowance','Vehicle_Allowance',' Vehicle1','Cellphone_Allowance',' Entertainment_Allowance',' Company_Car',' Medical_Allowance','DSocial_Security',' DHousing_Allowance','DCompany_Car','DContributions','Other_Deductions','DVehicle_Allowance','Other_Allowance','Total_Income','Taxable_Income','Tax_Payable','Overtime','Overtime_Hours','Payday','Pension','Provident_Fund','Retirement_Annuity','Study_Policy','Month','Year','Company')";
$result3 = mysqli_query($conn, $fields_arr);
$arr = mysqli_fetch_assoc($conn, $result3);
$fields = implode(',',$arr);