-1
I have a link that comes from a while
in php and receives several lines of IDs
. while puts id’s in the variable $dataid=$row['id'];
Receive the IDs
on 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 link referred to. 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 to pass values IDs
correct for the modal when I click on the link?
The links contain the IDS
correct, only that when I go to the modal I lose the ID
. How can I fix this?
Edit your question and add the repeat loop as well... where you do the
while
and where you mount html.– Marllon Nasser
Let’s continue this discussion in chat.
– Marllon Nasser