Pass id modal window

0

I can not pass an id to a modal window. Could you help me?

The code for the main page code is this:

menu.php

$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:

menu.php

<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

page.php

<?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>
    
asked by anonymous 19.10.2017 / 00:39

2 answers

1

You could do so

<a href="?id=<?php echo $_GET["id"]; ?>#pagina1" class="btn_modal">

In the menu.php file, also take a space that has

.load("pagina.php "+url)

So stop

.load("pagina.php"+url)
    
19.10.2017 / 01:10
0

I created one of the following form 1 made my PHP , and called the page where the modal was in the button (In the case to edit). With the id of my variable that in the case is this excerpt

<a href="editar/editarnovidades.php?id_img=<?php echo $rs['id_img']; ?>" ...

Code below hope it helps.

<div class="container-fluid">
<?php 
include('conect.php');
$consulta = "SELECT * FROM novidade";
$cons = mysqli_query($conect_phpmyadmin,$consulta);
while ($rs = mysqli_fetch_array($cons))
    {
        $nome = $rs['nome_img'];
        $desc = $rs['descprod_imagem'];
        $imagem = "uploads/".$rs['desc_img'];
?>
<div class="col-sm-6 col-md-4">
    <div class="thumbnail">
        <img src="<?php echo $imagem;?>" alt="Produto da loja" width="275" heigth="150">
        <div class="caption">
            <h3><?php echo $nome; ?></h3>
        </div>
        <p><?php echo $desc; ?></p>
        <p><a href="editar/editarnovidades.php?id_img=<?php echo $rs['id_img']; ?>" data-toggle="modal" data-target="#myModal" class="btn btn-primary" role="button">Editar</a> 
        <a href="excluir/excluircheck.php?id_img=<?php echo $rs['id_img']; ?>" data-toggle="modal" data-target="#myModal" class="btn btn-default" role="button"
        onclick="return confirm('Deseja excluir o produto?');">Apagar</a></p>
        <div class="modal fade" id="myModal" role="dialog">
            <div class="modal-dialog">      
            <div class="modal-content">
            </div>
            </div>
        </div>
    </div>
</div>
<?php } ?>
</div>
    
19.10.2017 / 00:53