显示行在Bootstrap中折叠了

时间:2018-10-19 07:23:14

标签: php mysql row

$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。

1 个答案:

答案 0 :(得分:0)

现在可以了。我现在要做的事情:

 $ccid = "#$current_id";
 $ccid2 = "$current_id"; 

然后我将变量放在ID和Href中,如下所示:

href='".$ccid."'
id='".$ccid2."'

解决了这个问题。谢谢大家!