I am newbie in this thing, i have searched on internet but not work for me, maybe someone can give me solution to get data from two array from json encode
<?php
session_start();
include "config.php";
$viewEO;
$viewAcara;
$ideve=mysql_real_escape_string($_GET["id"]);
$mysql = ("SELECT id_eo,nama as namaEO,logo,deskripsi as DeskEO,email,telp from eventorg WHERE id_eo='$ideve'");
$result=mysql_query($mysql);
if (!empty($result))
{
while ($row=mysql_fetch_array($result))
{
$viewEO[] = array(
'idEO' => $row['id_eo'],
'namaeo' => $row['namaEO'],
'deskripsieo' => $row['DeskEO'],
'email' => $row['email'],
'telpon' => $row['telp'],
'logoeo' => $row['Logo']
);
}
}
$mysql2 = ("SELECT id_acara,nama,tanggal,endtanggal,lokasi,imagePath,deskripsi,id_eo from acara WHERE id_eo='$ideve'");
$result2=mysql_query($mysql2);
if (!empty($result2))
{
while ($row2=mysql_fetch_array($result2))
{
$viewAcara[] = array(
'idacara' => $row2['id_acara'],
'namaacara' => $row2['nama'],
'deskripsi' => $row2['deskripsi'],
'tanggal' => $row2['tanggal']
);
}
}
mysql_close($con);
$final = array('array1'=>$viewEO, 'array2'=>$viewAcara);
header('Content-Type: application/json');
echo json_encode($final);
?>
and this is my html code
var arrEOS=new Array();
$.ajax({
url: 'phpmobile/viewdetaileo.php',
data: { "id": tempideo},
dataType: 'json',
success: function(data){
$.each(data, function(i,item){
if (arrEOS.indexOf(item.ideo)<0)
{
$('#daftaracara').append('<li data-role="list-divider" >'+item.tanggal+'</li><li><a onclick="detailAcara('+item.idacara+')"><h2>'+item.nama+'</h2><p><strong>'+item.deskripsi+'</strong></p><p>'+item.lokasi+'</p></a></li>');
arrEOS.push(item.idacara);
}
$('ul').listview('refresh');
$("#img1").html('<img id="img1" src="web/'+item.logoeo+'">');
$("#namaeo").html(item.namaeo);
$("#deskEO").html(item.deskripsieo);
$("#telpon").html(item.telpeo);
$("#email").html(item.emaileo);
});
},
error: function(){
//output.text('There was an error loading the data.');
}
});
Thank you before, Have a nice day :)