Foros del Web » Programando para Internet » PHP »

ayuda con encuestador

Estas en el tema de ayuda con encuestador en el foro de PHP en Foros del Web. Hola a todos, una ve mas les escribo para pedir su ayuda, tengo el siguiente dilema: necesito crear una hoja php en donde me diga ...
  #1 (permalink)  
Antiguo 17/08/2008, 18:14
 
Fecha de Ingreso: mayo-2008
Mensajes: 148
Antigüedad: 15 años, 11 meses
Puntos: 1
ayuda con encuestador

Hola a todos, una ve mas les escribo para pedir su ayuda, tengo el siguiente dilema: necesito crear una hoja php en donde me diga los resultador de la siguiente encuesta: que me indique con barras y numeros lo siguiente:
cantidad total d vicitas = xxx
mujer = xxx
hombre = xxx
Código PHP:
<?php require_once('../Connections/origen.php'); ?>
<?php
function GetSQLValueString($theValue$theType$theDefinedValue ""$theNotDefinedValue ""
{
  
$theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue;

  switch (
$theType) {
    case 
"text":
      
$theValue = ($theValue != "") ? "'" $theValue "'" "NULL";
      break;    
    case 
"long":
    case 
"int":
      
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case 
"double":
      
$theValue = ($theValue != "") ? "'" doubleval($theValue) . "'" "NULL";
      break;
    case 
"date":
      
$theValue = ($theValue != "") ? "'" $theValue "'" "NULL";
      break;
    case 
"defined":
      
$theValue = ($theValue != "") ? $theDefinedValue $theNotDefinedValue;
      break;
  }
  return 
$theValue;
}

$editFormAction $_SERVER['PHP_SELF'];
if (isset(
$_SERVER['QUERY_STRING'])) {
  
$editFormAction .= "?" htmlentities($_SERVER['QUERY_STRING']);
}

if ((isset(
$_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
  
$insertSQL sprintf("INSERT INTO encuesta (sex) VALUES (%s)",
                       
GetSQLValueString($_POST['sexo'], "text"));

  
mysql_select_db($database_origen$origen);
  
$Result1 mysql_query($insertSQL$origen) or die(mysql_error());

  
$insertGoTo $_from['index_apa.php'];
  if (isset(
$_SERVER['QUERY_STRING'])) {
    
$insertGoTo .= (strpos($insertGoTo'?')) ? "&" "?";
    
$insertGoTo .= $_SERVER['QUERY_STRING'];
  }
  
header(sprintf("Location: %s"$insertGoTo));
}
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Documento sin t&iacute;tulo</title>
</head>

<body> 
<form action="<?php echo $editFormAction?>" method="POST" enctype="application/x-www-form-urlencoded" name="form1" id="form1">
  <p>Seleccione su Sexo:</p>
  <p>
    <input name="sexo" type="radio" value="Femenino" onclick="document.form1.boton.disabled=false"/>
    Mujer
    <input name="sexo" type="radio" value="Masculino" onclick="document.form1.boton.disabled=false"/>
    Hombre
  </p>
  <p>
    <label>
    <input type="submit" name="Submit" id="boton" value="Aceptar" disabled="disabled" />
    </label>
</p>
  <input type="hidden" name="MM_insert" value="form1">
</form>
</body>
</html>
de antemano muchas gracias
  #2 (permalink)  
Antiguo 19/08/2008, 10:56
 
Fecha de Ingreso: mayo-2008
Mensajes: 148
Antigüedad: 15 años, 11 meses
Puntos: 1
Respuesta: ayuda con encuestador

Bueno después de buscar en varios sitios logre hacer una hoja q me diera los resultados, ahora estoy buscado la forma de hacer que me aparezca al lado de cada resultado el porcentaje que representa cada uno, aquí les dejo el código Porcia les sirve a alguno, y ojala puedan ayudarme a resolver el tema de los porcentajes

Cita:
<?php require_once('Connections/xxxx.php'); ?>
<?php require_once('Connections/xxxx.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;

$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}

mysql_select_db($database_xxxx, $xxxx);
$query_totalhombres = "SELECT Count(sex) FROM encuesta_sex where sex='Masculino'";
$totalhombres = mysql_query($query_totalhombres, $xxxx) or die(mysql_error());
$row_totalhombres = mysql_fetch_assoc($totalhombres);
$totalRows_totalhombres = mysql_num_rows($totalhombres);

mysql_select_db($database_xxxx, $xxxx);
$query_Mujer = "SELECT Count(sex) FROM encuesta_sex where sex='Femenino'";
$Mujer = mysql_query($query_Mujer, $xxxx) or die(mysql_error());
$row_Mujer = mysql_fetch_assoc($Mujer);
$totalRows_Mujer = mysql_num_rows($Mujer);

mysql_select_db($database_xxxx, $xxxx);
$query_total = "SELECT Count(sex) FROM encuesta_sex";
$total = mysql_query($query_total, $gobierno) or die(mysql_error());
$row_total = mysql_fetch_assoc($total);
$totalRows_total = mysql_num_rows($total);
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Documento sin t&iacute;tulo</title>
<style type="text/css">
<!--
.Estilo1 {
font-family: Arial, Helvetica, sans-serif;
font-weight: bold;
font-size: 18px;
color: #FF00FF;
}
.Estilo2 {
font-family: Arial, Helvetica, sans-serif;
color: #0000FF;
font-size: 18px;
font-weight: bold;
}
.Estilo3 {
color: #009933;
font-weight: bold;
font-size: 18px;
font-family: Arial, Helvetica, sans-serif;
}
.Estilo4 {font-family: Arial, Helvetica, sans-serif}
.Estilo5 {font-family: Arial, Helvetica, sans-serif; font-weight: bold; }
-->
</style>
</head>

<body>

<div align="center">
<p><img src="imagenes/banner.jpg" alt="xxxxx" width="780" height="137" /> </p>
<p>&nbsp;</p>
<p class="Estilo4">texto que quieran</p>
<table width="300" border="1" cellpadding="0" cellspacing="0" bordercolor="#000000">
<tr>
<td><span class="Estilo1">Total de Mujeres:</span></td>
<td><?php echo $row_Mujer['Count(sex)']; ?></td>
</tr>
<tr>
<td><span class="Estilo2">Total de Hombres:</span></td>
<td><?php echo $row_totalhombres['Count(sex)']; ?></td>
</tr>
<tr>
<td><span class="Estilo3">Total General:</span></td>
<td><?php echo $row_total['Count(sex)']; ?></td>
</tr>
</table>
<p class="Estilo5"><a href="index.php">Volver a Inicio</a></p>
</div>
</body>
</html>
<?php
mysql_free_result($Mujer);

mysql_free_result($total);

mysql_free_result($totalhombres);
?>
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 08:39.