i have problem with getting info in my modal form. I have rows what shows information. Screen shot bellow

Then i press button right im getting modal window. Screen shot bellow

I want make then i press my button in right get what row info and put in input.
My code in php and html
<div>
<table>
<?php
$query = $con->query("SELECT * FROM education WHERE education_id='".$info['nick_id']."' ORDER BY start_date");
while ($row = $query->fetch_assoc())
{
?>
<tr>
<b><?=$row['name']?></b><br>
<?=$row['specelybe']?> <span style="float:right;"> <button type="button" class="btn" class="btn btn-primary" data-toggle="modal" data-target="#exampleModalCenter"> <i class="fa fa-pencil fa-2x" style="color:black;" aria-hidden="true"></i> </button> </span> <br>
<?=$row['start_date']?> - <?=$row['end_date']?> <br>
</tr>
<?php
}
?>
</table>
</div>
MY MODAL FORM code
<!-- Modal -->
<div class="modal fade" id="exampleModalCenter" tabindex="-1" role="dialog" aria-labelledby="exampleModalCenterTitle" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLongTitle">Išsilavinimo redagavimas</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<input type="text" name="nameuni" placeholder="NAME of uni" required>
<br>
<input type="text" name="namestudc" placeholder="NAME of program" required>
<br>
<input type="date" name="startdate" placeholder="START DATE" id="startdate" required>
<br>
<input type="date" name="endDate" placeholder="END DATE" id="endDate" required>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary">Save changes</button>
</div>
</div>
</div>
</div>
My js code
<script>
$('#myModal').on('shown.bs.modal', function () {
$('#myInput').trigger('focus')
})
</script>
I try make table then select like row something like what
var data = table.row( $(this).parents('tr') ).data();
But its now work for me. Maybe u have some solution? All help will be appreciated
Advertisement
Answer
first off all don’t need change table structure to do it. So first of all i change button to <a>
<table>
<?php
$delLinijos = 0;
$query = $con->query("SELECT * FROM education WHERE education_id='".$info['nick_id']."' ORDER BY start_date");
while ($row = $query->fetch_assoc())
{
?>
<tr>
<b><?=$row['name']?></b><br>
<?=$row['specelybe']?> <span style="float:right;"> <a href="#" data-toggle="modal" data-target="#educationModal<?=$row['id']?>" > <i class="fa fa-pencil fa-2x" style="color:black;" aria-hidden="true"></i> </a></span> <br>
<?=$row['start_date']?> - <?=$row['end_date']?> <br>
</td>
</tr>
<?php
}
?>
</table>
Important place is <a href="#" data-toggle="modal" data-target="#educationModal<?=$row['id']?>" > for this stuff i can send row id to my modal form window.
so modal form in html looks like this.
<div class="modal fade" id="educationModal<?php echo $row['id']; ?>" tabindex="-1" role="dialog" aria-labelledby="educationModalLabel<?php echo $row['id']; ?>" aria-hidden="true">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
</div>
<div class="modal-body">
<hr class="style17">
<input type="text" name="namestudc" value="<?php echo $row['name']; ?>" id="name" required>
<br>
<input type="text" name="specelybe" value="<?php echo $row['specelybe']; ?>" id="specelybe" required>
<br>
<input type="date" name="startdate" value="<?php echo $row['start_date']; ?>" id="startdate" required>
<br>
<input type="date" name="endDate" value="<?php echo $row['end_date']; ?>" id="endDate" required>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Uždaryti</button>
<button type="button" class="btn btn-primary">Išsaugoti</button>
</div>
</div>
</div>
</div>