【发布时间】:2018-10-19 07:23:14
【问题描述】:
$i = 0;
while($row = $statement->fetch()) {
$current_id = 'id-' . $i;
$i++;
echo "
<tr>
<td>
<p>
<button class='btn btn-primary'
type='button'
data-toggle='collapse'
data-target='#<?=$current_id?>'
aria-expanded='false'
aria-controls='Collapse'>
Button with data-target
</button>
</p>
<div class='collapse' id='<?=$current_id?>'>
<div class='card card-block'>
Here is the content for block which will be shown when the button. This uses button with data-target attribute for collapsing.
</div>
</div>
</td>
";
}
我的错误在哪里?它不会折叠,但我需要行的唯一 ID。
【问题讨论】:
-
不确定它是否能解决您的问题。除非在复制到您的问题时出错,否则您的
while循环缺少右括号}。 -
这个
}是不是只有这个td 的一个片段,崩溃的地方是:) 但是我的代码中有这个}:) 这个错误只在我更改数据目标时出现像#ttt 和 id 到 ttt 一样正常,然后它会变形,但通过这个尝试我不会:) -
bootstrap initially collapsed element 的可能重复项 - 我认为您需要
<div class='accordian-body collapse' id...。 -
顺便说一句,我添加了一个结束
}只是为了完整性。 -
class='accordian-body collapse' id...不适合我。