• 用JavaScript动态生成HTML(PHP+MYSQL)(2)


    若上一篇不够清晰,这是第二个例子。

    1):表

    2):

    3):

    <?php
    namespace appsanwudaichaocontroller;
    use thinkController;
    use thinkDb;
    header('Access-Control-Allow-Origin:*');
    header('Access-Control-Allow-Methods:OPTIONS, GET, POST'); // 允许option,get,post请求
    header('Access-Control-Allow-Headers:x-requested-with'); // 允许x-requested-with请求头
    header('Access-Control-Max-Age:86400'); // 允许访问的有效期
    class Bank extends Controller
    {
    // 连接
    private $dbcon;

    public function __construct(){
    // $this->dbcon = Db::connect("mysql://root:@127.0.0.1:3306/test#utf8");
    $this->dbcon = Db::connect(".......");
    }
     
    public function getBankInfo(){
    $id = $_POST['xly'];
    if($id==1){
     
    $arr=array();
    $proInfo = $this->dbcon->table('bank')->select();
    foreach ($proInfo as $key => $value) {
    $temp=array();
    $imgSrc=$value['bank_img'];
    $intr=$value['bank_introduction'];
    $name=$value['bank_name'];
    $link=$value['bank_link'];
    $earn=$value['bank_earn'];
    $passrate=$value['passingrate'];
    $applynum=$value['applynum'];
    array_push($temp, $imgSrc,$intr,$name,$link,$earn,$passrate,$applynum);
    array_push($arr, $temp);
    // array_push($arr,$temp);
    // array_push(array, var)
    }
    $arr_json=json_encode($arr);
    echo $arr_json;
    }
     
    }

    }
  • 相关阅读:
    web前端页面性能优化小结
    css3倒影
    jUploader: 基于jQuery文件上传插件
    java 异常的总结
    java 接口
    java 类的成员四初始化块
    java 集合总结
    java 操作集合的工具类Collections
    java 包装类及字符串与基本数据类型间的转换
    单例设计模式
  • 原文地址:https://www.cnblogs.com/TuringShine/p/10157382.html
Copyright © 2020-2023  润新知