dongzaocheng3214 2018-02-03 09:56
浏览 68

PHP MYSQL Json问题

We have a simple php mysql json api to provide data to android app

We have a fix categories.

so we just check if category is this then fetch result from mysql database and convert in json

Everything is working fine. Fetching url from mysql

$stm_row = $stm->fetchAll(PDO::FETCH_ASSOC);

Till here all is working fine. data is coming from every category

Then, we convert data to JSON:

print(json_encode($stm_row));

But the problem is that only 1 catgory data is printing using json, rest category data showing blank

Can you please check what can be issue

  • 写回答

2条回答 默认 最新

  • dongshanyan0322 2018-02-03 10:14
    关注

    i am giving you simple demonstration how to work with json.you can try like that

    $data=array();
    while($row = mysqli_fetch_array($query)) {
      $data[] = $row['your field name'];
    }
    echo json_encode(array("response"=>$data));
    
    评论

报告相同问题?

悬赏问题

  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器