<bdo id='iySml'></bdo><ul id='iySml'></ul>
  1. <tfoot id='iySml'></tfoot>

  2. <i id='iySml'><tr id='iySml'><dt id='iySml'><q id='iySml'><span id='iySml'><b id='iySml'><form id='iySml'><ins id='iySml'></ins><ul id='iySml'></ul><sub id='iySml'></sub></form><legend id='iySml'></legend><bdo id='iySml'><pre id='iySml'><center id='iySml'></center></pre></bdo></b><th id='iySml'></th></span></q></dt></tr></i><div id='iySml'><tfoot id='iySml'></tfoot><dl id='iySml'><fieldset id='iySml'></fieldset></dl></div>

    1. <small id='iySml'></small><noframes id='iySml'>

    2. <legend id='iySml'><style id='iySml'><dir id='iySml'><q id='iySml'></q></dir></style></legend>
    3. php+mysql将数据库查询结果返回为Json格式

      时间:2024-05-15

      • <i id='0kZVu'><tr id='0kZVu'><dt id='0kZVu'><q id='0kZVu'><span id='0kZVu'><b id='0kZVu'><form id='0kZVu'><ins id='0kZVu'></ins><ul id='0kZVu'></ul><sub id='0kZVu'></sub></form><legend id='0kZVu'></legend><bdo id='0kZVu'><pre id='0kZVu'><center id='0kZVu'></center></pre></bdo></b><th id='0kZVu'></th></span></q></dt></tr></i><div id='0kZVu'><tfoot id='0kZVu'></tfoot><dl id='0kZVu'><fieldset id='0kZVu'></fieldset></dl></div>

              <bdo id='0kZVu'></bdo><ul id='0kZVu'></ul>
              <legend id='0kZVu'><style id='0kZVu'><dir id='0kZVu'><q id='0kZVu'></q></dir></style></legend>

              <small id='0kZVu'></small><noframes id='0kZVu'>

                  <tbody id='0kZVu'></tbody>
                <tfoot id='0kZVu'></tfoot>
                php+mysql将数据库查询结果返回为Json格式,实例代码如下:
                <?php
                  // 配置json 
                  header("Content-type: application/json;charset=UTF-8");
                  // 跨域配置
                  header("Access-Control-Allow-Credentials: true");
                  header("Access-Control-Allow-Origin: *");
                
                  $conn = mysqli_connect('localhost','root','123456','genbanorg');	
                  mysqli_query($conn,"set character set 'utf8'");
                  mysqli_query($conn,"set names 'utf8'");
                	$result=mysqli_query($conn,"select * from prolist");
                  $jarr = array();
                	while ($rows=mysqli_fetch_array($result)){
                	    $count=count($rows);//不能在循环语句中,由于每次删除 row数组长度都减小  
                	    for($i=0;$i<$count;$i++){  
                          unset($rows[$i]);//删除冗余数据
                	    }
                	    array_push($jarr,$rows);
                	} 
                  $json = JSON_encode($jarr,JSON_UNESCAPED_UNICODE);
                  $arr = json_decode($json);
                  echo $json;
                  // echo $arr;
                	// echo $str=json_encode($jarr);//将数组进行json编码
                ?>
                
                 
                上一篇:php获取数据库中数据的实现方法 下一篇:没有了

                相关文章

                1. <i id='v4jew'><tr id='v4jew'><dt id='v4jew'><q id='v4jew'><span id='v4jew'><b id='v4jew'><form id='v4jew'><ins id='v4jew'></ins><ul id='v4jew'></ul><sub id='v4jew'></sub></form><legend id='v4jew'></legend><bdo id='v4jew'><pre id='v4jew'><center id='v4jew'></center></pre></bdo></b><th id='v4jew'></th></span></q></dt></tr></i><div id='v4jew'><tfoot id='v4jew'></tfoot><dl id='v4jew'><fieldset id='v4jew'></fieldset></dl></div>
                  <tfoot id='v4jew'></tfoot>

                2. <small id='v4jew'></small><noframes id='v4jew'>

                  1. <legend id='v4jew'><style id='v4jew'><dir id='v4jew'><q id='v4jew'></q></dir></style></legend>
                      <bdo id='v4jew'></bdo><ul id='v4jew'></ul>