我可以从 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/