I want to pass the value of the php / postgresql query to the modal but I am not able to.
I have a PivotTable that lists the results. In one of these columns I want to include the modal (popup) button and pass the line id to the modal in order to query the database.
My table:
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td>col1</td>
<td>col2</td>
<td>col3</td>
<td>col4</td>
<td>col5</td>
<td>col6</td>
</tr>
<?php
while($row = pg_fetch_assoc($query)){
?>
<tr>
<td><?php echo $row['col1'];?></td>
<td><?php echo $row['col2'];?></td>
<td><button type="button" class="popup-botao" data-toggle="modal" data-target="#myModal" data-id="<?php echo $row['id'];?>"><?php echo $row['col3'];?></button>
<!-- Modal -->
<div class="modal fade" id="myModal" role="dialog">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content">
<?php
$id = $row['col3'];
$qry_modal = pg_query($conn,"select * from table where id = $id");
$row_modal = pg_fetch_assoc($qry_modal);
?>
<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 echo $row_modal['col10'];?></div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
<?php } ?>
</td>
<td><?php echo $row['col4'];?></td>
<td><?php echo $row['col5'];?></td>
<td><?php echo $row['col6'];?></td>
</tr>
<?php } ?>
</table>