I have a link that comes from a while
in php and receives several lines of IDs
. The while puts the id's in the variable $dataid=$row['id'];
Receive the IDs
in the link
$sql = "SELECT u.id, u.username, u.genero, u.idade, u.local, u.descricao, u.status,u.last_login, u.photo_p_id, p.location
FROM user AS u
LEFT JOIN photos AS p
ON u.photo_p_id=p.id
WHERE genero='m'
order by u.last_login DESC
LIMIT 8
";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc()) {
$dataid=$row['id'];
<a id='teste' data-id=".$dataid." 'class='teste' data-toggle='modal' data-target='#bannerformmodal'>teste</a>
}else{
echo "nada";
}
When I click on the link and the modal form appears, the $dataid
is not the same as the referral link. It is always the last record that while returned.
Modal form
<div class='modal fade bannerformmodal' tabindex='-1' role='dialog' aria- labelledby='bannerformmodal' aria-hidden='true' id='bannerformmodal'>
<div class='modal-dialog modal-sm'>
<div class='modal-content'>
<div class='modal-content'>
<div class='modal-header'>
<button type='button' class='close' data-dismiss='modal' aria-hidden='true'>×</button>
<h4 class='modal-title' id='myModalLabel'>Enviar mensagem</h4>
</div>
<div class='modal-body'>
<form id='requestacallform' method='POST' name='requestacallform' action="">
<div class='control-group'>
<div class='controls'>
<textarea id='msg' type='text' name='msg' placeholder='Mensagem'><?php echo $dataid; ?></textarea>
</div>
</div>
<button type='submit' class='btn btn-blue'>Enviar</button>
</form>
</div>
<div class='modal-footer'>
</div>
</div>
</div>
</div>
</div>
How do I pass the correct IDs
values to the modal when I click the link?
The links contain the correct IDS
, so when I go to the modal I lose ID
. How can I resolve this?