zoukankan      html  css  js  c++  java
  • jump display

    查找了数据库,再在while里拼接成json是很麻烦的,所以,jump display

    获得数组

    <?php
    
    header("Content-Type:text/html; charset=utf-8");
    
    /*json接口测试*/
    $g=$_GET['g'];
    $v=$_GET['v'];
    $msu=$_GET['msu'];
    print_r ($g);
    print_r ($v);
    print_r ($msu);
    /*json*接口测试*/
    
    
    
    //进行my数据库连接
    $con = mysql_connect("localhost","root","root");
    if (!$con)
      {
      die('Could not connect: ' . mysql_error());
      }
    
    mysql_query("set names utf8");//ut8声明
    mysql_select_db("examples", $con);//打开my里的数据库
    
    //显示my里的用户数据以便于添加参照
    $my = mysql_query("SELECT name FROM `think_form` WHERE city = '上海' AND groupName = '专家'");
    
    
    echo "[";
    while($a=mysql_fetch_array($my))
      {
    echo json_encode($a['name']).",";
    }
    echo "]";
    
    ?>

    再次修改显示内容,还可以做个伪接口

    <?php 
    //get传值
    header("Content-Type:text/html; charset=utf-8");
    $g=$_GET['g'];
    $urlg = "http://localhost/a.php?g=".$g ; 
    $contentsg = file_get_contents($urlg); 
    //如果出现中文乱码使用下面代码 
    //$getcontent = iconv("gb2312", "utf-8",$contentsg); 
    echo preg_replace('(,])',']',$contentsg);//preg_replace(find,被替换成,字符串)
    echo "<br>";
    ?> 

    接口本来要传很多的参数,但是天晚了,想的费功夫,多写几个伪接口页面就得了。。。

  • 相关阅读:
    Python 入门 之 print带颜色输出
    memcache缓存
    PDO
    面向对象(二)
    面向对象(一)
    文件上传
    简单的权限管理
    当前时间与时期联动
    淡入淡出、滑动、及遍历
    留言板相关功能
  • 原文地址:https://www.cnblogs.com/hellowzd/p/4163825.html
Copyright © 2011-2022 走看看