<?php
//parse_ini_file($filename);
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of info
 *
 * @author TyKayn
 */


class info {
	//put your code here
		public $rendu='';
		public $sondage_actuel='';
		public $nb_votes_sondage_actuel='';
		public $grades='';	//grades du sondage grade1,grade2,grade3...
		public $questions=''; //tableau [num_q]=>[type 	requis 	stat 	defaut 	illustration 	points 	titre]
		public $dernier_s='';
		
		
		private function connect(){
			try{
					// On se connecte à MySQL
							
					$pdo_options[PDO::ATTR_ERRMODE] = PDO::ERRMODE_EXCEPTION;
					$bdd = new PDO('mysql:host=localhost;dbname=tykayn', 'tykayn', 'plopplop01', $pdo_options);
					}
						catch(Exception $e){
						die('Erreur : '.$e->getMessage());
					}
		}
		
	//pour tout savoir sur un sondage
	public function __construct($id_sondage){
					try{
					// On se connecte à MySQL
							
					$pdo_options[PDO::ATTR_ERRMODE] = PDO::ERRMODE_EXCEPTION;
					$bdd = new PDO('mysql:host=localhost;dbname=tykayn', 'tykayn', 'plopplop01', $pdo_options);
					}
						catch(Exception $e){
						die('Erreur : '.$e->getMessage());
					}
					try{
						// On liste les sondages
					 $reponse = $bdd->query('SELECT *
											FROM tkp_sondages');
					 }
						catch(Exception $e){
						die('Erreur : '.$e->getMessage());
					}
					 //compte les votes
					$nb_votes=0;
						while ($donnees = $reponse->fetch())
						{
							//$reponse['id'];
						}
						
						
						$this->nb_votes_sondage_actuel=$nb_votes;
						$reponse->closeCursor();
		
	}
	public function dern_s(){
		try{
					// On se connecte à MySQL
							
					$pdo_options[PDO::ATTR_ERRMODE] = PDO::ERRMODE_EXCEPTION;
					$bdd = new PDO('mysql:host=localhost;dbname=tykayn', 'tykayn', 'plopplop01', $pdo_options);
					}
						catch(Exception $e){
						die('Erreur : '.$e->getMessage());
					}
		$reponse = $bdd->query('SELECT COUNT(*)FROM tkp_sondages');
		
		$donnees = $reponse->fetch();
			$this->dernier_s=$donnees;	
		echo ' num du dernier sondage: '.$donnees;
		
	
	}
}

?>
