1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
   |  
/*---------------------------------------------------------------------------------------------------------------*/
/*---------------------verification si rating fait et affichage des liens de vote--------------------------------*/
/*---------------------------------------------------------------------------------------------------------------*/
$mail_user=$infouser['mail'];
 if(isset ($_GET["valeurrating"]))//si le parametre valeurrating existe donc que l'user a demandé a effectuer un rating.
{
    $valeurrating=$_GET["valeurrating"];
 
    if($valeurrating=="plus")
    {
	$requete['insertRatingPlus']="INSERT INTO rating(id_rating, id_fichier, ip_votante, vote) VALUES (nextval('auto_inc_rating_id_rating'), ".$id_post.", '".$mail_user."', 'plus')";
	$traitement=$sql->TabResSQL($requete['insertRatingPlus']);
	header('Location: index.php?page=viewpost&post_id='.$id_post);
 
    }
    else
    {
        $requete['insertRatingMoins']="INSERT INTO rating(id_rating, id_fichier, ip_votante, vote) VALUES (nextval('auto_inc_rating_id_rating'), ".$id_post.", '".$mail_user."', 'moins')";
	$traitement=$sql->TabResSQL($requete['insertRatingMoins']);
	header('Location: index.php?page=viewpost&post_id='.$id_post);
    }
}
 
$requete["ratingExist"]="select count (*) from rating where ip_votante = '".$mail_user."' AND id_fichier = ".$id_post;
$requete["ratingAime"]="select count (*) from rating where ip_votante = '".$mail_user."' AND id_fichier = ".$id_post." AND vote='plus'";
$requete["ratingAimePas"]="select count (*) from rating where ip_votante = '".$mail_user."' AND id_fichier = ".$id_post."AND vote='moins'";
$countAime=$sql->TabResSQL($requete["ratingAime"]);
$countMoins=$sql->TabResSQL($requete["ratingAimePas"]);
$ratingExiste=$sql->TabResSQL($requete["ratingExist"]);
 
//Construction du tableau contenant les lien pour le rating ainsi que les ratings du post.
if(($ratingExiste[0][0])==0)//si l'user n'a pas encore voté
{
	//$sortiehtml.="<table style='width: 5px;'><tr>";
	$sortiehtml.="<th><a href='index.php?page=viewpost&post_id=".$id_post."&valeurrating=plus' id='link'><img src='../management/pictures/ratingplus.gif' alt='j/'aime' title='vote j aime' height='30' width='30'/></a><br/><span style='color:black;'>".$countAime[0][0]."</span></th>";
	$sortiehtml.="<th><a href='index.php?page=viewpost&post_id=".$id_post."&valeurrating=moins' id='link'><img src='../management/pictures/ratingmoins.gif' alt='j\'aime' title='vote j aime pas' height='30' width='30'/></a><br/><span style='color:black;'>".$countMoins[0][0]."</span></th>";
	//$sortiehtml.="</tr><tr>";
	//$sortiehtml.="<td>".$countAime[0][0]."</td>";
	//$sortiehtml.="<td>".$countMoins[0][0]."</td>";
	//$sortiehtml.="</tr></table>";
}
else//Si l'user a deja voté
{
	//echo ("<table><tr>");
	$sortiehtml.="<th><img src='../management/pictures/ratingplusNB.gif' alt='j/'aime' title='vote j aime' height='30' width='30'/><br/><span style='color:black;'>".$countAime[0][0]."</span></th>";
	$sortiehtml.="<th><img src='../management/pictures/ratingmoinsNB.gif' alt='j\'aime' title='vote j aime pas' height='30' width='30'/><br/><span style='color:black;'>".$countMoins[0][0]."</span></th>";
	//echo ("</tr><tr>");
	//echo ("<td>".$countAime[0][0]."</td>");
	//echo ("<td>".$countMoins[0][0]."</td>");
	//echo ("</tr></table>");
}
/*---------------------------------------------------------------------------------------------------------------*/
/*--------------------/verification si rating fait et affichage des liens de vote--------------------------------*/
/*---------------------------------------------------------------------------------------------------------------*/ | 
Partager