I am currently developing a PM system for my CMS and I thought I would include jQuery too make the inbox page a little more "cool"
I can't show you how it works live so I uploaded some pictures of it.
In closed.jpg you can see how it looks like when the user hasn't opened a message yet. When the user clicks "Mikey", the message should slide down but insted, every message slides down from every user.
I know what the poblem is but I don't know how to fix it, I'm not that good at jQuery, yet:)
I guess you have to pass on the ID of person to jQuery so that the right message slides down, but I don't know how:)
jQuery
$(".from_user").click(function(){
$(".show_pm").slideToggle("slow");
})
PHP & HTML
<div id="table">
<table width="700" border="0" cellpadding="10" cellspacing="0" id="inkorg_table">
<tr>
<td><strong>Från:</strong></td>
<td><strong>Ämne:</strong></td>
<td><strong>Radera:</strong></td>
</tr>
';
$inkorg = mysql_query("SELECT * FROM pm WHERE pm.to_user='".$_SESSION['username']."' AND pm.deleted=0 ORDER BY ID DESC") or mysqlError();
while($row = mysql_fetch_array($inkorg)){
print '
<tr '.is_pm_new($row['id']).'>
// When the user clicks this link, the message from this person should slide down
<td><a href="#" class="from_user">'.$row['from_user'].'</a></td>
<td>'.protect($row['subject']).'</td>
<td><a href="index.php?page=pm&inkorg&move_trash='.$row['id'].'"><img src="img/remove.png" width="16" height="16" alt="remove" /></a></td>
</tr>
// This is where the message begins
<tr class="show_pm">
<td colspan="3">';
// Get msg
print '<div id="inkorg">
<p><strong>Från:</strong> '.$row['from_user'].'</p>
<p><strong>Till:</strong> '.$row['to_user'].'</p>
<p><strong>Datum:</strong> '.$row['sent_at'].'</p>
<p><strong>Ämne:</strong> '.protect($row['subject']).'</p>
<p>'.nl2br($row['body']).'</p>
}
}
print '</div>
</div>
</div>';
print '</td>
</tr>';
}// End while-loop
print '
</table>
</div>
';
I removed a little bit of code that you don't need, so if you notice too many </divs>, don't worry about them.
Thanks:P
