Passing ID by modal parameter

0

I have the following problem, I have a PHP $Id fault that I need to receive it in the modal to make a SELECT in the table, and fetch information in the DB.

The button it is on one page, and the modal on another, and I made the include to be able to call the modal, when I click the button it does not pass the $ Id.

<button type="button" data-toggle="modal" data-target="#ModalDetalhes" data-id="<?php echo $Id; ?>">
    <img src="Imagens/Detalhes.png" width="36" height="20">
</button> 

I'll try to post my code line to show my problem:

Arquivo OrdermServico.php

<?php
include("All_Modals");
$Busca = mysql_query("SELECT * FROM OrdemServico WHERE Status ='$Status'", $con -> conexaoMysqlP()) or die (mysql_error());
    $ContCampos = mysql_num_rows($Busca);
        $Consulta = mysql_fetch_array($Busca);
?>
<?php
if($ContCampos > 0) {
    do {
?>
<table>
<tr>
<td width="130px"><?=$Consulta["Status"]?></td>
<td width="380px"><?=@$Consulta["LaudoTecnico"] ?></td>
<td width="115px" align="center">
aqui preciso pegar o $ID 
    <?php 
    $Id = $Consulta["id"];
     ?>
<a href="" data-target="#ModalDetalhes" data-toggle="modal">Abrir Modal</a>

    </td>
</tr> 
</table>    
<?php
}while ($Consulta = mysql_fetch_assoc($Busca));

}
?>

All_Modals.php file

<div class="modal fade" id="ModalDetalhes" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
<div class="modal-dialog" role="document">
<div class="modal-content">
  <div class="modal-header">
    <?php
    //Aqui preciso receber a variavel php para usar no select

    echo $Id;
        // Seleciona tabela o id para editar, excluir ou etc
            $query_Recordset1 = sprintf("SELECT * FROM OrdemServico WHERE id = '$Id'", $con -> conexaoMysqlP()) or die (mysql_error());
                $Recordset1 = mysql_query($query_Recordset1);
                    $row_Recordset1 = mysql_fetch_assoc($Recordset1);

        <div class="form-inline">  
            <div class="form-group">
                <label>OS Detalhes</label>
            </div>     
<div class="modal-body">
<php //Aqui irei montar o restante do codigo php ?>
<div class="modal-footer">
            <input type="submit" class="btn btn-primary" name="BotaoEnviar">      
  </div>
</form>      
</div>
</div>
</div>
</div>  
    
asked by anonymous 19.08.2016 / 01:22

1 answer

1

Frames,

To do this type of call I usually use a modal looking for the URL remotely, so I already pass the parameter by the direct URL, as below:

<a data-target="#remoteModal" data-toggle="modal" href="http://www.site.com.br/arquivoRemoto.php?variavel=parametro" class="btn btn-nav active" type="button">
ABRIR MODAL
</a>
    
19.08.2016 / 02:20