How to pass data from the database to modal

1

Hello, I have a website offline and I'm in need of a function that I think is complex. I wanted, when loading an image, that comes from the database, open a modal with the information about it. I'll explain, my site is about companies and when we upload an image of the company I wanted to open a modal with the rest of the information, contacts, location, etc ...

<div class="col-md-12" style="margin-top:20px">
    <div class"container-fluid">
        <div class="row" align="center">
            <?php
                $empresas="SELECT * FROM empresa ORDER BY Nome";
                $query_empresas=$ligacao->query($empresas) or die ('erro ligacao');

                while($linha=$query_empresas->fetch_assoc())
                {     
            ?>          
                <div class="col-md-3">
                    <div class="novoPortfolio-box printdesign">
                        <a href="empresas.php?id=<?php echo ($linha["idEmpresa"]);?>"  data-toggle="modal" data-target="#empresa" ><img src="imgempresas/<?php echo ($linha["idEmpresa"]) ?>.png"> </a>
                        <!--href="empresas.php?id=<?//php echo ($linha["idEmpresa"]);?>" -->                               
                            <h3><?php echo (htmlentities($linha["Nome"],ENT_QUOTES,"ISO-8859-1"));?></h3>
                            <p><?php echo (htmlentities($linha["Localidade"],ENT_QUOTES,"ISO-8859-1"));?></p>                           
                    </div>
                </div>
            <?php
                }
            ?>
        </div>
    </div>    
</div>

<div class="modal fade" id="empresa" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
                        <div class="modal-dialog">
                            <div class="modal-content">
                                <div class="modal-header" style="text-align:center">
                                    <strong>Empresa <?php echo (htmlentities($linha["Nome"],ENT_QUOTES,"ISO-8859-1"));?></strong> 
                                </div>
                                <div class="modal-body">
                                    <form action="" method="post">
                                        <fieldset>
                                            <div class="form-group">
                                                <label for="name" class="cols-sm-2 control-label">Nome Completo</label>
                                                <div class="input-group">
                                                    <span class="input-group-addon"><i class="glyphicon glyphicon-user"> </i> </span>
                                                    <input type="text" class="form-control" id="nome_reg" name="nome_reg" placeholder="Insira aqui o seu nome." required autofocus />
                                                </div>
                                            </div>
                                        </fieldset>
                                    </form>
                                </div>
                            </div>
                        </div>        
                      </div>    
    
asked by anonymous 13.03.2017 / 20:00

0 answers