特定行上的bootstrap表离子

时间:2015-09-04 00:02:51

标签: php sql twitter-bootstrap-3 html-table

我可以从JSON输出成功显示引导程序表但是我不知道如何填充最后一列上的按钮以显示在每一行

<table class = "table table-hovergrey" data-search="true"  data-toggle="table" data-url="php/data.php" data-height="auto">
            <thead>
                <tr>
                    <th data-field="ID">ID</th>
                    <th data-field="Name">Name</th>
                    <th data-field="Age">Age</th>

                </tr>
            </thead>
        </table> 

PHP代码

<?php
   // DB Credentials goes here
        $db_name  = 'dbName';
        $hostname = 'hostname';
        $username = 'username';
        $password = 'password'; 
// connect to the database

 $dbh = new PDO("mysql:host=$hostname;dbname=$db_name", $username, $password);

// a query get all the records from the users table
        $sql = 'select ID,Name,Age from PEOPLE ';

// use prepared statements, even if not strictly required is good    practice
        $stmt = $dbh->prepare( $sql );

        // execute the query
        $stmt->execute();

        // fetch the results into an array
        $result = $stmt->fetchAll( PDO::FETCH_ASSOC );

        // convert to json
        $json = json_encode( $result );

        // echo the json string
        echo $json;
?>

1 个答案:

答案 0 :(得分:0)

我没有足够的代表发表评论 - 但我不确定您是如何填充表格的 - 也许您有自定义指令data-url

这是从Angular控制器通过$http抓取JSON数据的标准示例(通常你会在服务中进行http调用,但为了演示......)。

HTML是模板化的,并使用ng-repeat来创建表格行。这样您就可以完全控制标记,并且可以轻松创建<button>。以下是Codepen的一个工作示例:http://codepen.io/TheFoot/pen/bVdrxQ