PHP:
Create a table in your database:
CREATE TABLE `your_database`.`messages` (
`id` INT PRIMARY KEY AUTO_INCREMENT ,
`subject` VARCHAR( 50 ) NOT NULL ,
`recipient_id` INT ,
`sender` INT ,
`message` TEXT NOT NULL
) ENGINE = MYISAM ;
Includes the jQuery, CSS, and PHP markup
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
$(function(){
$(
"#delete").
click(function(){
$(
"input[type=checkbox]:checked").each(function(){
var v = $(
this).val();
$(
"div#"+v).remove();
});
});
$(
"input[type=checkbox]").
click(function(){
var x = $(
"input[type=checkbox]:checked").length;
var t = $(
"input[type=checkbox]").length;
if(t==x){
$(
".chktoggle").val(
"Uncheck All").attr(
"id",
"unchkall");
}
else
{
$(
".chktoggle").val(
"Check All").attr(
"id",
"chkall");
}
});
$(
"#chkall").live(
"click", function(){
$(
"input[type=checkbox]").each(function(){
$(
this).attr(
"checked",
true);
});
$(
this).val(
"Uncheck All").attr(
"id",
"unchkall");
});
$(
"#unchkall").live(
"click", function(){
$(
"input[type=checkbox]").each(function(){
$(
this).attr(
"checked",
false);
});
$(
this).val(
"Check All").attr(
"id",
"chkall");
});
});
</script>
<style>
#messages div:first-child
{
border-top: 1px #32baed solid;
width: 600px;
}
#demo div
{
border-left: 1px #32baed solid;
border-right: 1px #32baed solid;
border-bottom: 1px #32baed solid;
border-top: none;
width: 600px;
}
#chk, input[type=button] {
cursor: pointer;
}
</style>
</head>
<body>
<?php
session_start();
$username =
$_SESSION["username"];
$q =
mysql_query(
"SELECT * FROM messages WHERE username='$username'");
<div class="messages">
while(
$r=mysql_fetch_array($q))
{
$id =
$r[
"id"];
$subject =
$r[
"subject"];
$sender =
$r[
"sender"];
$message =
$r[
"message"];
echo '<div class="comment" id="'.$id.'"><table width="100%"><tr><td>'.$sender.'</td><td><input id="chk" type="checkbox" value="'.$id.'"></td><td>'.$subject.'</td><td>'.$message.'</td></tr></table></div>';
}
</div>
?>
</body>
</html>
Views: 478 Likes: 1 Dislikes: 0