Ver Mensaje Individual
  #1 (permalink)  
Antiguo 24/06/2007, 14:52
Borjimante
Invitado
 
Mensajes: n/a
Puntos:
No recuenta los votos

Hola tengo este codigo:

Código PHP:
<?
mysql_connect
('localhost','xxx','xxx')or die('ERROR EN LA CONEXION :'.mysql_error());
mysql_select_db('xxx')or die('ERROR AL ESCOJER LA BD :'.mysql_error());

function 
show_encuesta($id_ENCUESTA,$proteccion_IP){
// COLOCO TODAS MIS PREGUNTAS Y OPCIONES 
$encuesta[1]=array('&iquest;Que te parece el nuevo dise&ntilde;o?',array('Muy bueno','Bueno','Normal','Malo','Asqueroso'));
//END 
if (!array_key_exists($id_ENCUESTA,$encuesta)) return ('El id de la encuesta no se encuentra disponible');
else
$pregunta_de_la_encuesta array_shift($encuesta[$id_ENCUESTA]);
$opciones_de_la_encuesta array_pop ($encuesta[$id_ENCUESTA]);
if(isset(
$_POST[opcion])){
$ssqls=mysql_query('SELECT * FROM encuesta_blt WHERE ip="'.$REMOTE_ADDR.'"')or die(mysql_error());
if(
$proteccion_IP && mysql_num_rows($ssqls)>=1){
$html_encuesta='<font color="#1D59C9" face="tahoma"  size="2"><strong>Usted ya ha votado en esta encuesta</strong></font>';

}
else {
mysql_query('INSERT INTO encuesta_blt VALUES("'.$id_ENCUESTA.'","'.$_POST[opcion].'","'.$REMOTE_ADDR.'")')or die(mysql_error()); }
}

$ssql=mysql_query('SELECT * FROM encuesta_blt WHERE id_encuesta="'.$id_ENCUESTA.'"')or die(mysql_error());
$total_votos=mysql_num_rows($ssql);


// IMPRIMIR LOS RESULTADOS.
$html_encuesta.='<form action="'.$_SERVER[REQUEST_URI].'" method="POST">';
$html_encuesta.= '<font color="#666666" face="tahoma"  size="2"><strong>'.$pregunta_de_la_encuesta.'</strong></font><br>';
$html_encuesta.='<br>';
foreach(
$opciones_de_la_encuesta as $KEY => $OPCION){
$ssql=mysql_query('SELECT * FROM encuesta_blt WHERE id_encuesta="'.$id_ENCUESTA.'" and id_opcion="'.$KEY.'"')or die(mysql_error());
$votos_x_opcion=mysql_num_rows($ssql);
$estimar_porcentaje= @round($votos_x_opcion*100/$total_votos,1);
$html_encuesta.= '<table style="width: 200px; height: 20px; border: 0px;"><tr style="display: inline;"><td style="display: inline; text-align: left; width: 20px;"><input name="opcion" type="radio" value="'.$KEY.'"';
if(
$_POST[opcion]==$KEY && isset($_POST[opcion])){$html_encuesta.='checked'; }
$html_encuesta.= '></td><td style="display: inline; text-align: left;">'.$OPCION.' '.$estimar_porcentaje.' %</td> <strong> <td style="display: inline; width: 50px; text-align: left;"><div style="background-color:#1D59C9; border: 1px solid #999999; font-size: 5px; width:'.$estimar_porcentaje.'%;"></div></td></tr></table></strong> <br>';
}

$html_encuesta.='<input type="submit" value="Votar">';
$html_encuesta.='</form>';
return 
$html_encuesta;
}
?>
en que falla?¿