Foros del Web » Programando para Internet » PHP »

Cuestionario de Preguntas PHP

Estas en el tema de Cuestionario de Preguntas PHP en el foro de PHP en Foros del Web. Buenas Noches Soy nuevo en esto de a programación, estoy intentado montar un software estilo cuestionario. Hasta ahora, tengo las preguntas montadas en a base ...
  #1 (permalink)  
Antiguo 09/06/2015, 18:10
Avatar de r10r9k22  
Fecha de Ingreso: junio-2015
Ubicación: Caracolicito
Mensajes: 2
Antigüedad: 8 años, 10 meses
Puntos: 0
Información Cuestionario de Preguntas PHP

Buenas Noches

Soy nuevo en esto de a programación, estoy intentado montar un software estilo cuestionario.

Hasta ahora, tengo las preguntas montadas en a base de datos y he logrado hacer la consulta ademas de lograr darle formato a para ver de forma presentable las preguntas y posibles respuestas.

Pero quiero poder mostrar as preguntas 1 a 1, cada vez que de clic en siguiente se guarde el resultado y muestre a la siguiente pregunta.

Envío el código que he resuelto hasta ahora.

Agradecería me ayudaran con parte del código que debo adicionarle para realizar a consulta pregunta por pregunta.

Código PHP:
<?php
header
("Content-Type: text/html;charset=utf-8");
require 
"ConexionDatos.php";
extract ($_REQUEST);
$objConexion = new mysqli($host,$user,$password,$baseDatos);
    if (
$objConexion->connect_errno)
    {
    echo 
"Problemas en la Conexion "$objConexion->connect_error;
    exit();
    }
$hacer_trampa=1;
$idPregunta=1;
$sql="SELECT * from preguntas where idPregunta = '$idPregunta'";
$acentos $objConexion->query("SET NAMES 'utf8'");
$resultado=$objConexion->query($sql);
$a=0;
while (
$pregunta=$resultado->fetch_array())
{
$pregunta1[]=$pregunta['pregunta'];
$respuesta[$a][0]=$pregunta['preRespuestaCorrecta'];
$respuesta[$a][1]=$pregunta['preRespuestaIncorrecta'];
$respuesta[$a][2]=$pregunta['preRespuestaIncorrecta2'];
$respuesta[$a][3]=$pregunta['preRespuestaIncorrecta3'];   
$_SESSION['idPregunta'][$a]=$pregunta['idPregunta'];
$a++;
?>
<table align="center" width="70%" border="3" bordercolor="#0000FF" cellpadding="5">
<tr>
<td align="center"><font face="Arial, Helvetica, sans-serif" size="+2"><?php  echo "Area: ".$pregunta['preCategorias'?></font></td>
</tr>
<tr>
<td align="center"><font face="Arial, Helvetica, sans-serif" size="+2"><?php  echo "Nivel: ".$pregunta['preNiveles'?></font></td>
</tr>
<?php
}

mysqli_free_result($resultado);
    foreach(
$pregunta1 as $indice=>$valor)
    {
        
$arrayAleatorio range(03);
        
shuffle($arrayAleatorio);
        
$nuevoIdCorrecta=array_search("0",$arrayAleatorio);
        
$_SESSION['array'][$indice]=$arrayAleatorio;
        
?>
<tr>
<td align="justify"><?php  echo $pregunta1[$indice?></tr>
</tr>  
    <tr>
    <td align="justify"><?php
        
foreach($arrayAleatorio as $indice1=>$valor1)
        echo 
"<input type=\"radio\" name=\"Pregunta".$indice."\" value=\"".$valor1."\" />"$respuesta[$indice][$arrayAleatorio[$valor1]] . ( ( $valor1 == $nuevoIdCorrecta && $hacer_trampa) ? "" "" ) . "<br />\n";?>
</tr>
<tr>
        <td align="center"><input type="submit" name="button" id="button" value="Siguiente" /></td>
        </tr>
        </table>
        </br>
<?php
    
}
?>

Etiquetas: cuestionario, html, mysql, preguntas, select, sql
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 18:59.