【发布时间】:2015-06-21 21:18:33
【问题描述】:
我有这个带有 rfid mac 标签数据的表格。我想在弹出窗口中显示这些标签,并在按下它时显示一些额外的信息。但它不会像表本身那样改变它的值。弹出框似乎重复了它给出的第一个值。如何在每个 while 循环后更改弹出框的值?
<div class="panel panel-default panel-success">
<div class="panel-heading">
<h3 class="panel-title">Items inside</h3>
</div>
<table class="table table-bordered text-center">
<?php
$result = mysqli_query($con, "SELECT item_tag, item_status FROM item WHERE item_status = 1;") or die(mysql_error());
$i = 0;
while ($row = mysqli_fetch_array($result)){
$i++;
//if this is first value in row, create new row
if ($i % 3 == 1) {
echo "<tr>";
}
?>
<td>
<div>
<span class="btn" id="infoItem" data-toggle="popover" rel="popover">
<?php echo $row[0] ?>
</span>
</div>
</td>
<script>
$(document).ready(function () {
$('[data-toggle="popover"]').popover({
html: true,
animation: false,
content: '<?php echo $row[0] ?>',
placement: "bottom"
});
});
</script>
<?php
//if this is third value in row, end row
if ($i % 3 == 0) {
echo "</tr>";
}
}
//if the counter is not divisible by 3, we have an open row
$spacercells = 3 - ($i % 3);
if ($spacercells < 3) {
for ($j = 1; $j <= $spacercells; $j++) {
echo "<td></td>";
}
echo "</tr>";
}
?>
</table>
</div>
这是我第一次使用 html/php/mysql/bootstrap 应用程序。
【问题讨论】:
标签: php mysql twitter-bootstrap popover