0
I have the following problem, I have a $Id
PHP I need to receive it in modal to make a SELECT
in the table, and search for information in the BD.
The button it sits on one page, and the modal on another, and I made the include to call the modal, when I click on 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 will try to post my line of code 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));
}
?>
File All_modals.php
<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>
Is it Bootstrap? That should work, are you passing the right variable? It has the same name? I saw above
$id
and then$Id
. Sometimes things like that happen ;)– Jorge B.
It is yes, No and direct no, the modal button I have on one page, and the modal on another, then I called with the include... the modal opens, but I can’t pass the value of $Id through the data-id="<? php echo $Id; ?>"
– Marcos Marciel Pagung
Is this what you want? http://jsfiddle.net/k7FC2/1440/
– Jorge B.
Show amigo, it worked, but I need a php variable, because I need to make a select in modal, type if possible in js o <input type="text" name="bookId" value=""/> were the variable, unfortunately I’m starting now and I’m layman with JS... and php dominate well already!
– Marcos Marciel Pagung
Use $_Session. And Zera when you finish the code.
– Willian Coqueiro
@Jorgeb. your example worked partly, but in the modal display the id correctly, but I need the <input[name="bookId"> receive via php, for example: $id ='<input type="text" name="bookId" value="""/>';, but it doesn’t work rsrs, could you give me another help? Because there in the modal I will do one more select, to filter and display the data of this $Id. Thanks in advance!
– Marcos Marciel Pagung