I have a problem with select distinct and calculate my data. I am on restful web service server side. And I made service like this :
private function grafik()
{
if($this->get_request_method() !="GET")
{
$this->response('',406);
}
$sql = "select distinct operating_system from data";
$query = $this->mysqli->query($sql) or die($this->mysqli->error.__LINE__);
//$query = mysql_query( $sql ) or die(mysql_error());
while( $ret = $query->fetch_array() ){
$os=$ret['operating_system'];
$sql_jumlah = "SELECT * FROM data WHERE operating_system='$os'";
$query_jumlah = $this->mysqli->query($sql_jumlah) or die($this->mysqli->error.__LINE__);
$data = mysqli_num_rows( $query_jumlah );
$jumlah = $mydata;
echo $jumlah;
echo $os;
The problem is I'm really confused on how I can get $jumlah
and $os
on different variable into client side with
$json = file_get_contents('http://localhost/proejct/services/server');
When i echo $json
, I get both of $jumlah
and $os
on $json
, but I want to get that in 2 different variables. What should I do?