<?php 

class tesla_coil {
	public $conn, $table;
	
	public function database_define($DBServerName, $DBUserName, $DBPassword, $DBName, $table){
		// Define the table name, and connect to the database.
		$this->table = $table;
		$this->conn = mysqli_connect($DBServerName, $DBUserName, $DBPassword, $DBName);
	}
	
	public function save_data($coil, $fan){
		// Save new commmands to the table.
		$sql = "UPDATE `$this->table` SET `coil`='$coil', `fan`='$fan' WHERE id=1";
		if(mysqli_query($this->conn, $sql)){ echo "SAVED!<br>Coil => ".$coil."<br>Fan => ".$fan; }else{ echo 'ERROR!'; }

	}
	
	public function print_data(){
		// Print the current command variables.
		$sql = "SELECT * FROM `$this->table` WHERE id=1";
		$result = mysqli_query($this->conn, $sql);
		while($rows = mysqli_fetch_assoc($result)){
			echo '%'.$rows['coil'].'%'.$rows['fan'].'%';
		}
	}
}

?>