Ver Mensaje Individual
  #1 (permalink)  
Antiguo 26/03/2008, 14:37
Avatar de jakuam
jakuam
 
Fecha de Ingreso: abril-2007
Mensajes: 354
Antigüedad: 17 años
Puntos: 0
problema con codigo de Encuesta

Hola a como estan .. Estoy haceindo una esncuesta y encontre este codigo de una escuesta sensilla.. pero no logro hacer ya que no me sakle nada cuando abro el archivo encuesta_blt.ini.php todo esta en blanco.. por favor ayuda necesito una encuesta urgente .. gracia y saludos

CREO TABLA MYSQL

CREATE TABLE `encuesta_blt` (
`id_encuesta` varchar(5) NOT NULL default '',
`id_opcion` varchar(5) NOT NULL default '',
`ip` varchar(15) NOT NULL default '' )
TYPE=MyISAM;

Codigo del Archivo encuesta_blt.ini.php

Código PHP:
<?php require_once('Connections/encuesta2.php'); ?> 
<?php

function show_encuesta($id_ENCUESTA,$proteccion_IP){
// COLOCO TODAS MIS PREGUNTAS Y OPCIONES
$encuesta[1]=array('¿Que Tecnologia utilizas?',array('Php','Asp','ColdFusion','Cgi','Perl','Jsp','Otra'));
//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="#FF0000" face="tahoma" size="2"><strong>Ya usted tiene un voto registrado</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.= '<strong>'.$pregunta_de_la_encuesta.'</strong>';
$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.= '<input name="opcion" type="radio" value="'.$KEY.'"';
if(
$_POST[opcion]==$KEY && isset($_POST[opcion])){$html_encuesta.='checked'; }

$html_encuesta.= '>'.$OPCION.' '.$estimar_porcentaje.'% <strong>Votos: '.$votos_x_opcion.'</strong> <br>';
}

$html_encuesta.='<br><input type="submit" value="Votar">';
$html_encuesta.='</form>';
return 
$html_encuesta;
}

?>
__________________
Jakuam
Reserva Hoteles Online
Turismo San Rafael Mendoza