Quick actions

cmd+k|ctrl+k

Navigation

Languages

Comment

Snippet info

Language

Php

Visibility

public

Author

mynameisjoker

Created

2016-09-02T13:01:48Z

Updated

2016-09-02T13:02:50Z

<?php

	/* The Comment Class */
	class Comment {
		
		private $mysqli;
		
		private static $mycomment = null; //It's means that I can add more and more comments
		
		/* Connecting... */
		
		public function __construct() {
			$this->mysqli = new Mysqli('localhost', 'root', '', 'cms');
			$this->mysqli->query("SET NAMES 'utf8'");
		}
		
		public static function getComment() {
			if(self::$mycomment === null) self::$mycomment = new Comment();
			return self::$mycomment;
		}
		
					/*Comment Functions*/
		public function viewComment($name, $comment)
		{
			$result_set = $this->mysqli->query("SELECT * FROM `articles` ORDER BY `id` DESC");
			while($result = $result_set->fetch_array()):
			print "$result[name] : $result[text_comment]<br>";
			endwhile;
		}
		
		
		public function addComment($name, $comment) 
		{
			if($name =="") return false;
			if($comment =="") return false;
			$this->mysqli->query("UPDATE `articles` SET `name` = '$name', `text_comment` = '$comment' WHERE(`id` = '$id')");
			
		}
		/* Closing the connection */
		
		public function __destruct() {
			if($this->mysqli) $this->mysqli->close();
		}
	
	
	
	
	
	
	
	
	
	
	}


?>
INFO