我通过制作数组($ from_user_array,$ type_array,$ subject_array和$ message_array)制作了一个收件箱,并通过将其放在带有for循环的html表中来显示数组中的内容。我已经从w3schools复制代码来制作模态。我知道错误必须在以下代码中的某处,因为其他一切都有效:
<?php foreach(range(0,$rowcount-1) as $i): ?>
<tr>
<td><?php echo $from_user_array[$i]; ?></td>
<td><?php echo $type_array[$i]; ?></td>
<td><button id = "<?php echo $i; ?>" onclick="click("<?php echo $i; ?>")">
Click to open</button></td>
</tr>
function click(ide){
<?php echo $i; ?>
// Get the modal
var modal = document.getElementById("myModal");
// Get the button that opens the modal
var btn = document.getElementById(ide);
// Get the <span> element that closes the modal
var span = document.getElementsByClassName("close")[0];
// When the user clicks the button, open the modal
btn.onclick = function() {
modal.style.display = "block";
}
// When the user clicks on <span> (x), close the modal
span.onclick = function() {
modal.style.display = "none";
}
// When the user clicks anywhere outside of the modal, close it
window.onclick = function(event) {
if (event.target == modal) {
modal.style.display = "none";
}
}
}
<div id="myModal" class="modal">
<div class="modal-content">
<span class="close">×</span>
<p><b> subject: </b></p> </br>
<?php echo $subject_array[$i]; ?>
<p><b> message: </b></p> </br>
<?php echo $message_array[$i]; ?>
</div>
</div>
<?php endforeach; ?>
有谁知道这个问题是什么?