settings.php, file the important MySQL information Change the MySQL to your settings
<?php
//CONNECTS TO YOUR DATABASE (MODIFY TO YOUR SETTINGS) $c = mysql_connect("server", "username", "password"); $db = mysql_select_db("your_database", $c); $table = 'comments';
var id = $(this).attr("id").substr(1);
$("#a"+id).hide();
$(this).removeClass("more").addClass("less").text("Show Less");
$("#c"+id).show();
});
$(".less").live("click", function(){
var id = $(this).attr("id").substr(1);
$("#a"+id).show();
$(this).removeClass("less").addClass("more").text("Show More");
$("#c"+id).hide();
});
});
</script>
<style>
.content {
word-wrap:break-word;
width:600px;
}
.more:hover, .less:hover {
cursor:pointer;
text-decoration:underline;
}
.textfull {
display:none;
}
</style>
</head>
<body>
<?php
//FILE WITH THE IMPORTANT MySQL INFO include 'settings.php';
$q = mysql_query("SELECT * FROM $table ORDER BY id DESC");
while($r=mysql_fetch_array($q)){ $comment = $r["comment"]; $id = $r["id"]; //COMMENT ID $x = 250; //MAXIMUM NUMBER OF CHARACTERS $l = strlen($comment); //NUMBER OF CHARACTER IN THE COMMENT
//ABBREVIATES COMMENT IF EXCEEDS THE MAXIMUM if($l>$x){ $c = substr($comment, 0, $x).'...'; $comment = '<span id="a'.$id.'">'.$c.'</span><span class="textfull" id="c'.$id.'">'.$comment.'</span><br><span class="more" id="s'.$id.'">Show More</span>'; }
echo '<div class="content">'.$comment.'</div><br>'; //COMMENT DISPLAYED IN HTML }