I've decided to contribute what I have learn over the last couple of days in OOP programming. What the following basically does is displays comments in nicely formatted HTML code that one sees in comment sections of blogs and forums. Feel free to use it any or all of the code (or not), I just felt like contributing for people here over the last month have been really helpful to me and want to pay it back to people who might be getting started in php. It's a pretty simple php script, but it is done in Object Oriented Style. I think it gives it a little bit of more security of than doing it in procedural style, but this is just my opinion. I'm really digging this doing php in OOP.

Here's the PHP:
PHP Code:
class DatabaseConnection {
// Set-up array to fetch associative array from database
private $user_comment = array(
"id"      => "",
"title"   => "",
"content" => ""
$output;  // Notice this is the only public variable that is accessible directly. 
protected function fetch_database_comments() // protected - scope when you want to make your variable/function 
                                                  // visible in all classes that extend current class including the parent class.
$this->db = new mysqli("localhost""root""******""your_database");
// Do Not Use in Production
if (mysqli_connect_errno()) 
printf("Connect failed: %s\n"mysqli_connect_error());
$query "SELECT title, content FROM comments ORDER by id DESC LIMIT 5"// The Limit is set to 5 comments that can be displayed; however
                                                                                 // this is obviously changeable. 
if ($result $this->db->query($query)) {
/* fetch associative array */
            /* The following also sets it up in a nicely formatted HTML */
while ($row $result->fetch_assoc()) {
$this->thread_box  "<div id=\"user_box_style\">";
$this->thread_box .= "<fieldset class=\"user_fieldset\">";
$this->thread_box .= "<legend class=\"user_legend\">" nl2br($row['title']) . "</legend>";
$this->thread_box .= "<p class=\"user_text_color\">" nl2br($row['content']) . "</p>";
$this->thread_box .= "</fieldset>"
$this->thread_box .= "</div>";
$this->thread_box .= "<br />";
$this->output .= $this->thread_box;    
/* free result set */
/* close connection */

CommentBox extends DatabaseConnection {
    public function 
display_comments() {
// This grabs the formatted output data from the DatabaseConnection Class in order to output to the screen.
$this->output_comments $this->fetch_database_comments();
// This displays it...pretty simple right? 
echo $this->output_comments;    

HTML code:
<?php require("includes/user.comments.php"); ?>
<meta charset="utf-8">
<link href="css/user_style.css" rel="stylesheet" type="text/css" />


	$comments = new CommentBox;     	
	$comments->display_comments();  //Calls method to display formatted HTML data from database.	

and even the the css code.....

@charset "utf-8";
/* CSS Document */

#user_box_style {
	clear: left;
	width: 490px;
	border-radius: 15px;
	background-image: url(../images/img-text-bg-01.png);
		background-repeat: repeat;
	padding: 5px;
	margin: 10px 0px 0px 0px;		

.user_fieldset {
	width: 460px;

	border: 3px solid #00f;
	border-radius: 15px;

.user_legend, .user_text_color {
	color: #00f;	
Best Regards,

P.S. The code probably could still be written tighter, but like I said I'm just starting to fully grasp OOP myself.