0
I want to pass the value of php/postgresql query to modal but I’m not getting it.
I have a dynamic table that lists the results. In one of these columns I want to include the modal button (popup) and pass the id of the line to the modal in order to query the bank.
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>
woww why are you creating a model for each ? your html will be long
– 13dev
because I want the id line to query the database, it’s like I have a link in that column and open another page through so that through post or get used in a variable, but in this case instead of a link and new page I want to use a modal popup.
– user26858
And why don’t you just create a model and change the contents of the model when the user opens it? It’s unnecessary for each of you to save the id
– 13dev
put the modal out of the loop, is that it? yes, it is already
– user26858
yes and with javascript manipulates the data
– 13dev