我正在尝试使用 AJAX 从 PHP 中检索两个数组,但我认为json_encode
只能有一个变量。你知道我该如何解决这个问题吗?我是新手,正在使用json_encode
<?php
while($row = mysql_fetch_array($get_grades_boy)){
$data_grades_boys[]=array(
'fname_b'=>$row['firstname'],
'mname_b' => $row['middlename'],
'lname_b' => $row['lastname'],
'studnt_id_b' => $row['student_id'],
'grade_b' => $row['grade'],
);
}
while($row2 = mysql_fetch_assoc($get_grades_girl)){
$data_grades_girls[]=array(
'fname_g'=>$row2['firstname'],
'mname_g' => $row2['middlename'],
'lname_g' => $row2['lastname'],
'studnt_id_g' => $row2['student_id'],
'grade_g' => $row2['grade'],
);
}
echo json_encode($data_grades_boys);
我试着这样做
echo json_encode($data_grades_boys);
echo json_encode($data_grades_girls);
检索,但它没有工作。