My PHP code has a while that lists the registered users, from a MYSQL query.
This list of users shows photo , id , name and a link to open a modal. Here is the while code:
<?php
error_reporting(E_ALL ^ E_DEPRECATED);
$link = mysql_connect("localhost","root","") or die ("Não foi possível conectar servidor");
$banco = mysql_select_db('rscc-db', $link) or die ("Impossível conectar banco de dados");
$sql = mysql_query("SELECT id,nome,foto FROM tb_usuarios order by nome");
while ($dadosUsu = mysql_fetch_assoc($sql)) {
$id_usu = $dadosUsu['id'];
$nome_usu = $dadosUsu['nome'];
$foto_usu = $dadosUsu['foto'];
echo "<img src='fotos/".$foto_usu."' alt='Foto de exibição'; width='25'; height='30'; align='left'; /><br />";
echo $id_usu;
echo $nome_usu;
echo '<a href="#pagina" class="pagina click"> Info</a><br />';
}
?>
If you click on the "Info" link of any of the listed users, the modal window opens. Here is the JavaScript tag and the Divs structure of the modal:
<script type="text/javascript" src="jquery-1.9.1.js"></script>
<script type="text/javascript" src="core.js"></script>
<script type="text/javascript" src="jquery.cookie.js"></script>
<script type="text/javascript">
$(document).ready(function(e) {
if($.cookie('modal') !== undefined){
$('#modal').css('display','none');
}
$('.pagina').click(function(){
$('#modal').fadeIn(200);
});
$('.fechar, #modal').click(function(event){
if(event.target !== this){
return;
}
$('#modal').fadeOut(200);
$.cookie('modal', '1', { expires: 7 });
});
});
</script>
<div id="modal">
<div class="modal-box">
<div class="modal-box-conteudo">
<?php
error_reporting(E_ALL ^ E_DEPRECATED);
$link = mysql_connect("localhost","root","") or die ("Não foi possível conectar servidor");
$banco = mysql_select_db('rscc-db', $link) or die ("Impossível conectar banco de dados");
$sql = mysql_query("SELECT id,nome,email,foto FROM tb_usuarios where id='**$id_usuario**'");
---- continuação do código -----
?>
</div>
<div class="fechar">X</div>
</div>
</div>
I would like to know how I could store the id of the user that was clicked to use in this query within the Modal.