i have bootstrap table values database using select:
<table class="table table-hover table-bordered"> <thead> <tr> <th>studentnamn</th> <th>student id</th> <th>registrerade kurser</th> <th>betyg</th> </tr> </thead> <tbody> <?php include 'studentdb.php'; ?> </tbody> </table>
i want make table collapse , display inputform values on onclicked row can updated. have used following code:
$sql = "select student.studname, grades.studid, grades.courseid, grades.grade student inner join grades on student.studid=grades.studid"; try { foreach ($pdo->query($sql) $row) { echo '<tr data-toggle="collapse" data-target="#collapseupdate">'; echo '<td>' . $row['studname'] . '</td>'; echo '<td>' . $row['studid'] . '</td>'; echo '<td>' . $row['courseid'] . '</td>'; echo '<td>' . $row['grade'] . '</td>'; echo '</tr>'; echo '<tr>'; echo '<td colspan="6" class="hiddenrow" id="collapserow"><div class="accordian-body collapse" id="collapseupdate"> <div class="card card-block"> <form class="form-horizontal" action="update.php" method="post" id="newgrade"> <div class="control-group"> <label class="control-label">nytt betyg:</label> <div class="controls"> <p><input id="cbetyg" name="grade" type="text"></p> <input type="hidden" name="studid" value="'. $row['studid'] .'"> <input type="hidden" name="courseid" value="'. $row['courseid'] .'"> </div> </div> <div class="form-actions"> <input type="submit" name="submit" value="Ă„ndra"> </div> </form>
my problem here that, first row collapses , can use update. when click on other rows, first row collapses... can tell me can do? , also, update still work each individual row if make collapse work rows?
thanks!
you using same collapseupdate
target in field. try modify these lines:
instead
echo '<tr data-toggle="collapse" data-target="#collapseupdate">';
use
echo '<tr data-toggle="collapse" data-target="#collapseupdate'.$row['studid'].'">';
and instead
echo '<td colspan="6" class="hiddenrow" id="collapserow"><div class="accordian-body collapse" id="collapseupdate">
use
echo '<td colspan="6" class="hiddenrow" id="collapserow"><div class="accordian-body collapse" id="collapseupdate'.$row['studid'].'">
i suspect studid
unique in table.