Find det rigtige ID
Hej,Jeg har brug for at finde det rigtige ID (altså den valgte persons ID) når jeg trykker på en person. Data fra den valgte person skal vises i en popup-boks.
JS:
var tbody = '';
var myVar = 1;
$.each(data.members, function (index, item) {
tbody += '<tr>';
tbody += '<td align="left">' + myVar++ + '</td>';
tbody += '<td align="left">' + '<input type="button" data-toggle="modal" data-target="#myModal" id="' + item.id + '" />' + '</td>';
tbody += '<td align="left">' + item.fornavn + ' ' + item.efternavn + '</td>';
tbody += '<td align="left">' + item.age + '</td>';
$.each(item.workouts, function (index, date) {
if(date.date_id < 3)
if(date.status){
tbody += '<td align="left"> <input type="checkbox" name="member_'+item.id+'[]" value="'+date.date_id+'" checked disabled="disabled"></td>';
}else{
tbody += '<td align="left"> <input type="checkbox" name="member_'+item.id+'[]" value="'+date.date_id+' disabled="disabled"></td>';
} else {
if(date.status){
tbody += '<td align="left"> <input type="checkbox" name="member_'+item.id+'[]" value="'+date.date_id+'" checked"></td>';
}else{
tbody += '<td align="left"> <input type="checkbox" name="member_'+item.id+'[]" value="'+date.date_id+'"></td>';
}
}
});
tbody += '<td></td>';
tbody += '</tr>';
});
HTML/PHP:
<div id="myModal" class="modal fade" role="dialog">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">Modal Header</h4>
</div>
<div class="modal-body">
<?php
$sql = "SELECT * FROM tbl_medlem WHERE id = ".$_GET['id'];
$result = $conn->query($sql);
if ($result->num_rows > 0) {
while($row = $result->fetch_assoc()) {
echo $row["fornavn"];
}
} else {
echo "0 results";
} ?>
<p>Some text in the modal.</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
Jeg håber der er nogen der kan hjælpe mig :-)