0
I’m not getting an id to a modal window. Could you help me?
The excerpt from the main page code is this:
php menu.
$id= $_GET["id"];
<div style="text-align: center"><a href="#pagina1" class="btn_modal">
<h3>VER MAIS</h3></a></div>
<div id="modal">
<div class="box-modal">
<div class="box-modal-load"></div>
<div class="fechar">X</div>
</div>
</div>
This is the script that runs:
php menu.
<html>
<script type="text/javascript">
$(document).ready(function(e) {
$('.btn_modal').click(function(e){
e.preventDefault();
var url = $(this).attr('href')
$('.box-modal-load').load("pagina.php "+url);
$('#modal').fadeIn(500);
});
$('#modal, .fechar').click(function(e){
if( e.target !== this )
return;
$('#modal').fadeOut(500);
});
});
</script>
</html>
This is the modal window
php page.
<?php
$id = $_GET["id"];
$query4 = "SELECT
*
FROM
tabela
WHERE
idpessoa = $id";
$resultado4 = consultaQuery4($query4);
function consultaQuery4($query4)
{
include_once 'conexao2.php';
$consultaQuery4 = mysqli_query($connect, $query4);
return $consultaQuery4;
}
?>
<div id="pagina1">
<h1>Avaliações</h1>
<div class="avaliacaomodal">
<table class="table2modal">
<thead>
<tr>
</tr>
</thead>
<tbody class="cptabelaavamodal">
<?php while($ava = mysqli_fetch_array($resultado4)):?>
<tr class="registrosavamodal">
<td id="imgusermodal"><img src='<?php echo $ava['imagem'];?>' width="100" height="100"><?php echo nl2br ("<h7>".$ava['nome']."\n".$ava['data']."</h7>");?></td>
<td id="tabelaavamodal"><?php echo nl2br ("<h4>".$ava['comentario']."</h4>"."\n\n"."<h3>".$ava['nomeret']."\n".$ava['replica']."</h3>");?></td>
<td id="colunanotamodal"><?php echo nl2br ("<h1>".$ava['nota']."</h1>");?></td>
</tr>
<?php endwhile;?>
</tbody>
</table>
</div>
Who
ID
do you want to pass ? Can’t understand your question.– NoobSaibot
Sorry Wellington, I had forgotten to put rs. I was already editing. This id is a key to a query in the database that is already present in the menu page.php
– Everton Fraga
I reduced the code, but the main part is this. Where I click on the link "See more" and goes to the modal window (page.php). I did a test replacing the $id on the modal page with a bank id and the code worked. The biggest problem is passing this parameter.
– Everton Fraga
You could do it like this
<a href="?id=<?php echo $_GET["id"]; ?>#pagina1" class="btn_modal">
in the archivemenu.php
, also take a space that has in.load("pagina.php "+url)
leaves so.load("pagina.php"+url)
– NoobSaibot
Bro, ball show. What you gave me gave certin. Thank you so much! God bless
– Everton Fraga