Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $con = mysql_connect("localhost","root","");
- mysql_select_db("graph2", $con);
- $rkecam = mysql_query("select nama from kecamatan order by id_kec");
- while(list($nama) = mysql_fetch_row($rkecam)) { $category['kecamatan'][] = $nama; }
- mysql_free_result($rkecam);
- $rcalon = mysql_query("select id_calon, nama_calon from calon order by id_calon");
- while(list($id,$nama) = mysql_fetch_row($rcalon)) {
- $arrnama['nama'][] = $nama;
- $arrsuara = array();
- $rhasil = mysql_query("select suara from hasil where id_calon='$id' order by id_kec");
- while(list($suara) = mysql_fetch_row($rhasil)) { $arrsuara[] = $suara; }
- mysql_free_result($rhasil);
- $suara = join($arrsuara, ',');
- $data['hasil'][] = array("name"=>$nama,"data"=>$arrsuara);
- }
- mysql_free_result($rcalon);
- mysql_close($con);
- $result[] = $category; // json[0]
- $result[] = $data; // json[1]
- print json_encode($result, JSON_NUMERIC_CHECK);
- ?>
Advertisement
Add Comment
Please, Sign In to add comment