Good!
I'm doing a website at the university and it's the first time I use php, so I do not know much about the language and web development in general.
The problem I have is the following:
I have an array of objects called $ recibidos
where I have saved all the messages that a user has received (each message is an object) and I show them in a table such that:
<tbody>
<?php
for($i = 0; $i < count($recibidos); $i++) {
echo '
<tr>
<td><a onclick="leer()">'.$recibidos[$i]->getAsunto().'</a></td>
<td>'.$recibidos[$i]->getEmisor().'</td>
<td>'.$recibidos[$i]->getFecha().'</td>
</tr>
';
}
?>
</tbody>
The read () function only hides the table and shows the div to read the message (Everything is displayed on the same page).
So far so good, the problem is that I want that when I click on the subject field of the message I show you the corresponding message, but I do not know how to access it.
If I do something like this:
<div id="leer">
<div>
<label>De: </label> <?php echo $recibidos[$i]->getEmisor();?>
</div>
</div>
Obviously, it does not matter which message you click on because it is always going to show me the sender of the last message.
How can I do so by clicking on the first message read the fields of the first message? Do I have to create a separate variable or function, or is there some php function that allows me to do something like that?