Ich bin ein bisschen verwirrt, wie ich Antwortdaten wie diese erstellen.Daten erstellen JSON PHP
[
{
"profile": "Profile 1",
"kumpulan_spot": [
{
"urutan": "1",
"id": "0415AA9E2D",
"checkpoint": "3. OFFICE DEPAN LT. 2",
"lokasi": "WARU",
"waktu": "none",
"status": "none",
"kondisi": "none",
"foto": "none"
},
{
"urutan": "2",
"id": "0415AAA007",
"checkpoint": "4. OFFICE KRIAN LT.3 - R. MIS",
"lokasi": "KRIAN",
"waktu": "none",
"status": "none",
"kondisi": "none",
"foto": "none"
}
]
},
{
"profile": "Profile 2",
"kumpulan_spot": [
{
"urutan": "3",
"id": "0415AAA01B",
"checkpoint": "2. OFFICE DEPAN LT.1 - R. MARKETING",
"lokasi": "KRIAN",
"waktu": "none",
"status": "none",
"kondisi": "none",
"foto": "none"
}
]
}
]
aber so weit, was ich
$myparams['nik'] = $_POST['nik'];
$procedure_params = array(
array(&$myparams['nik'] , SQLSRV_PARAM_IN)
);
$sql = "EXEC SP_GETJADWAL @nik=?";
$stmt = sqlsrv_prepare($conn, $sql,$procedure_params);
if(!$stmt) {
die(print_r(sqlsrv_errors(), true));
}
$return_hasil=[];
$myArray = [];
if(sqlsrv_execute($stmt)){
do {
while ($row = sqlsrv_fetch_array($stmt, SQLSRV_FETCH_ASSOC)) {
$arrItem=[];
$detailItem=[];
// $i=0;
// while($i==0){
$arrItem["Profile"]="Profile ".$row['Profile'];
// $i=1;
// }
$detailCheckPoint=[];
$detailCheckPoint["urutan"]=$row['Urutan'];
$detailCheckPoint["id"]=$row['check_point_id'];
$detailCheckPoint["checkpoint"]=$row['check_point_name'];
$detailCheckPoint["lokasi"]=$row['check_point_loc'];
$detailCheckPoint["waktu"]="none";
$detailCheckPoint["status"]="none";
$detailCheckPoint["kondisi"]="none";
$detailCheckPoint["foto"]="none";
$detailItem[]=$detailCheckPoint;
$arrItem["ListCheckPoint"]=$detailItem;
$return_hasil[]=$arrItem;
}
} while (sqlsrv_next_result($stmt));
echo json_encode($return_hasil);
}else{
die(print_r(sqlsrv_errors(), true));
}
}else{
echo 'Connection Failure<br/>';
}
und führen bekommen versucht haben, wie diese
[
{
"Profile": "Profile 1",
"ListCheckPoint": [
{
"urutan": "1",
"id": "0415AA9E2D",
"checkpoint": "3. OFFICE DEPAN LT. 2",
"lokasi": "WARU",
"waktu": "none",
"status": "none",
"kondisi": "none",
"foto": "none"
}
]
},
{
"Profile": "Profile 1",
"ListCheckPoint": [
{
"urutan": "2",
"id": "0415AAA007",
"checkpoint": "4. OFFICE KRIAN LT.3 - R. MIS",
"lokasi": "KRIAN",
"waktu": "none",
"status": "none",
"kondisi": "none",
"foto": "none"
}
]
},
{
"Profile": "Profile 1",
"ListCheckPoint": [
{
"urutan": "3",
"id": "0415AAA01B",
"checkpoint": "2. OFFICE DEPAN LT.1 - R. MARKETING",
"lokasi": "KRIAN",
"waktu": "none",
"status": "none",
"kondisi": "none",
"foto": "none"
}
]
}
]
im neuen Daten json zu schaffen und wenig verwirrt, wie Reaktion zu erreichen, was ich wollen
Was ist das Problem? Das Format sieht korrekt aus. –
Sie möchten mehrere Arrays in "kumpulan_spot" einfügen. Unter welchen Umständen entscheidest du dich, Element in "kumpulan_spot" zu setzen? –
@TouheedKhan unter Bedingung $ arrItem ["Profil"] = "Profil". $ Row ['Profil']; sir so das Profil kann viele kumpulan_spot –