I have some items returned from the database that is listed in a table. To add an item, I call a modal in which I fill in the fields saving them to the bank. However, if this field is wrong, I need to edit it. The question is, how do I retrieve values for each row by clicking edit
to do a update in the bank?
See the code below as an example:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script><scriptsrc="http://getbootstrap.com/dist/js/bootstrap.js"></script>
<link href="http://getbootstrap.com/dist/css/bootstrap.css" rel="stylesheet"/>
<table border="1" cellspacing="1" cellpadding="5">
<thead>
<tr>
<th width="6%">Data</th>
<th width="40%">Descrição</th>
<th width="10%">Ação</th>
</tr>
</thead>
<tbody>
<tr>
<td rel="date">27/10/2016</td>
<td rel="description">Febre amarela</td>
<td rel="action">
<a data-toggle="modal" href="http://fiddle.jshell.net/bHmRB/51/show/" data-target="#myModal">Edit</a>
<a data-toggle="modal" href="#" data-target="#add">Delete</a>
</td>
</tr>
<tr>
<td rel="date">27/10/2016</td>
<td rel="description">Gripe suína</td>
<td rel="action">
<a data-toggle="modal" href="http://fiddle.jshell.net/bHmRB/51/show/" data-target="#myModal">Edit</a>
<a data-toggle="modal" href="#" data-target="#add">Delete</a>
</td>
</tr>
</tbody>
</table>
<!-- Modal -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h4 class="modal-title">Modal title</h4>
</div>
<div class="modal-body">
<form>
Descrição: <input type="text"/>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Fechar</button>
<button type="button" class="btn btn-primary">Salvar</button>
</div>
</div>
<!-- /.modal-content -->
</div>
<!-- /.modal-dialog -->
</div>
<!-- /.modal -->
Note: The delete button is only fictitious.
EDIT
I'm using PHP as back end to search for this data in the database.