/** * Created by PhpStorm. * User: Wu * Date: 12/22/15 * Time: 1:09 PM */ function getOrgData($keyword) { require_once "DataBaseEngine.php"; $db = new DataBaseEngine(); $stmt = $db->selectDataByOrg($keyword); $arr = array(); while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) { $date = $row['date']; $money = $row['money']; array_push($arr, array("year" => $date, "money" => $money)); } echo json_encode(array_values($arr)); }
<div id="myfirstchart2" style="height: 250px;"></div> <div class="table-responsive"> <table class="table table-striped"> <thead> <tr> <th>标题</th> <th>中标人</th> <th>金额</th> <th>日期</th> <th>来源</th> <th>操作</th> </tr> </thead> <tbody> HTML; $stmt = $db->selectDataByOrg($keyword); while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) { $title = $row['title']; $org = $row['org']; $money = $row['money']; $date = $row['date']; $spider = $row['spider']; $id = $row['id']; echo <<<HTML <tr> <td>{$title}</td> <td>{$org}</td> <td>{$money}</td> <td>{$date}</td> <td>{$spider}</td> <td><button type="button" class="btn btn-primary" onclick="showDetail({$id})">查看详情</button></td>