dongtan2017 2014-08-20 11:23
浏览 32

使用PHP计算使用Web服务选择distinct

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?

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 Vue3 大型图片数据拖动排序
    • ¥15 划分vlan后不通了
    • ¥15 GDI处理通道视频时总是带有白色锯齿
    • ¥20 用雷电模拟器安装百达屋apk一直闪退
    • ¥15 算能科技20240506咨询(拒绝大模型回答)
    • ¥15 自适应 AR 模型 参数估计Matlab程序
    • ¥100 角动量包络面如何用MATLAB绘制
    • ¥15 merge函数占用内存过大
    • ¥15 使用EMD去噪处理RML2016数据集时候的原理
    • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大