我刚刚开始学习代码并正在编写一些代码来回显一个数组,它给了我这个错误“警告:在第 62 行的 C:\xampp\htdocs\ogmt\rest_server_api.php 中为 foreach() 提供的参数无效”如何我解决了这个?这是我的代码:
if($Result1){
// script to get business no, amount & merchant id,output to merchant page
$query="SELECT * FROM customer_order WHERE insert_time=(SELECT max(order_time)from customer_order)";
$result=mysql_query($query);
while($row=mysql_fetch_assoc($result)){
$amount=$row['amount'];
$id=$row['merchant_id'];
$payment_mode=$row['mobile_service'];
switch($payment_mode){
case 'TIGO-PESA':
$result1=mysql_query("SELECT * FROM mobile_client WHERE mobile_service='TIGO-PESA'");
while($row1=mysql_fetch_assoc($result1)){
$data=array(
'Business no'=>$row1['business_no'],
'Payment Mode'=>$payment_mode,
'Total Amount Tsh'=>$amount,
'Merchant ID'=>$id
);
}break;
case 'M-PESA':
$result1=mysql_query("SELECT * FROM mobile_client WHERE mobile_service='M-PESA'");
while($row1=mysql_fetch_assoc($result1)){
$data=array(
'Business no'=>$row1['business_no'],
'Payment Mode'=>$payment_mode,
'Total Amount Tsh'=>$amount,
'Merchant ID'=>$id
);
}break;
case 'AIRTEL-MONEY':
$result1=mysql_query("SELECT * FROM mobile_client WHERE mobile_service='AIRTEL-MONEY'");
while($row1=mysql_fetch_assoc($result1)){
$data=array(
'Business no'=>$row1['business_no'],
'Payment Mode'=>$payment_mode,
'Total Amount Tsh'=>$amount,
'Merchant ID'=>$id
);
}break;
default:
$data=array('error'=>"no payment mode selected");
}
}
foreach( $data as $value ){
echo $value;
}
}
else{
echo "wrong";
}
}