Reputation: 1
I made an inbox by making arrays ($from_user_array, $type_array, $subject_array and $message_array) and showing what's in the arrays by putting it in an html table with a for loop. i've copied code from w3schools to make the modals. I know the mistake must be somewhere in the following code because everything else works:
<?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; ?>
anybody knows whats the problem?
Upvotes: 0
Views: 56