All pastes #185239 Raw Edit

Sans titre

public text v1 · immutable
#185239 ·published 2006-09-28 19:43 UTC
rendered paste body
//Affichage du sondage. 
  $vote_query = doquery ("SELECT * FROM {{table}} ORDER BY id DESC LIMIT 0,1", "sondage");
  $vote = mysql_fetch_array($vote_query);
  $ip_query = doquery ( "SELECT * FROM {{table}} WHERE numero='".$vote['id']."' AND ip='".$_SERVER['REMOTE_ADDR']."'","sondage_ip");
  $ip = mysql_num_rows($ip_query); 
   
  if (!empty($vote['question'])){
  
  $question = '<img  width="16px" height="15px" alt="" src="images/login/question.gif" style="vertical-align: middle;"/> <span class="marron2"><b>'.stripslashes($vote['question']).'</b></span><br /><br />';
  $bouton = '<div style="text-align: center" ><input type="image" src="images/login/bouton_voter.gif" class="no_bordure" title="Voter" name="sondage"/></div>';
  }else{
  
  $question = '<span class="marron2"><b>Aucun sondage</b></span>';
  $bouton = '';
 }
	
  $sondage = $question;
  $nbQuestions = 4;
  
  if (!isset($_POST["sondage_x"])) 
  {
  for($i=1 ; $i<=$nbQuestions ; $i++) {
   $check = ($i==1) ? 'checked' : '';
      $champ='reponse'.$i; 
        if(!empty($vote[$champ])) { 
        $sondage .= '<input type="radio" value="'.$i.'" name="reponse" '.$check.'> '.stripslashes($vote[$champ]).'<br />'; 
     } 
  }

  $sondage .= '<br />'.$bouton.'</div></form>'; 
  } 
  else 
  { 
  for($i=1 ; $i<=$nbQuestions ; $i++) {    
   $champ = 'resultat'.$i; 
      if($i==$_POST['reponse']) 
		{ 
        $update = $champ.'= '.$champ.' + 1';
    } 
  } 
  $save_vote = doquery("UPDATE {{table}} SET $update WHERE id='".$vote['id']."'", "sondage"); 
  $insert_ip = doquery("INSERT INTO {{table}} SET numero='".$vote['id']."', ip='".$_SERVER['REMOTE_ADDR']."'", "sondage_ip");

  $sondage = '<span class="marron1">Les résultats des votes:</span></div></form>';
   for($i=1 ; $i<=$nbQuestions ; $i++) {
      $champ='reponse'.$i;
        $nombre_vote='resultat'.$i; 	  
        if(!empty($vote[$champ])) {
          if($vote[$nombre_vote]>1){
            $pluriel = 'votes';	
			 }else{
			   $pluriel = 'vote';} 	
        $sondage .= '<span class="rose3"><b>- '.stripslashes($vote[$champ]).'</b></span> <span class="taille1">('.$vote[$nombre_vote].' '.$pluriel.')</span><br />'; 
     }
  }
}