php - 特定行上的自举表 ionic

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

我可以从 JSON 输出成功显示 Bootstrap 表,但是我不知道如何在最后一列上填充按钮以显示在每一行中

<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;
?>

最佳答案

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

这是一个通过 $http 抓取 JSON 数据的标准示例,来自 Angular Controller (通常您会在服务中执行 http 调用,但为了演示......)。

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

关于php - 特定行上的自举表 ionic ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32387256/

相关文章:

sql - 有没有办法限制左外连接?

sql - 为什么这个简单的查询不使用 postgres 中的索引?

c# - Bootstrap Style & Surrounding Div 标签来自 ASP.NET Code Behind

angularjs - ngBoilerplate+bootstrap -> 导航栏未显示正确

php - 如何在 magento 结帐时在运输方式中添加额外价格

php - 断言在 PHP 中不起作用。很简单。我究竟做错了什么?

php - 将键添加到数组 PHP 中尚无键的值

php - MySQL:向表中插入多行数据,一些数据来自另一个表(关系型)

mysql - 使用索引作为 ActiveRecord 属性

css - 使用 bootstrap 3 在水平表单布局下方居中对齐按钮