this is my script my friend but it doesnt work ,,,, and it doesnt show an
error just the page keep loading and loading and nothing
<?php
$var1=$_POST['fecha1'];
$var2= $_POST['fecha2'];
$server="localhost";
$username="root";
$password="chrystopher";
$databasename="encuestasavandaro";
try{
$db = new PDO("mysql:dbname=$databasename", $username, $password);
}
catch (PDOException $e){
die("{error: {$e ->getMessage()}}");
}
$db->setAttribute(PDO::ATTR_ERRMODE,PDO::ERRMODE_EXCEPTION);
$query1 = $db->prepare("SELECT * FROM testpower WHERE datetime > 0");
$query1 ->execute();
$results1 = $query1->fetchAll(PDO::FETCH_ASSOC);
$query = $db->prepare("
SELECT b.id_respuesta , COUNT(b.id_respuesta) AS cnt, b.id_aspecto
FROM huesped a, rompe_encuesta b
WHERE
b.id_huesped = a.id_huesped AND b.id_aspecto >= 1 AND b.id_aspecto <= 33 AND
a.fecha BETWEEN :fecha1 AND :fecha2
GROUP BY b.id_respuesta, b.id_aspecto
");
$parameters = array(
'fecha1' => $var1,
'fecha2' => $var2
);
try{
$query->execute($parameters);
$results = $query->fetchAll(PDO::FETCH_ASSOC);
}catch (PDOException $e){
die("{error: {$e->getMessage()}}");
}
$table = array();
$table['cols']=array(
array('label' => 'Type' , 'type' => 'string'),
array('label' => 'Count' , 'type' => 'number'),
array('label' => 'Aspecto', 'type' => 'number')
);
$rows = array();
foreach ($results as $r){
$temp = array();
// using (int) $variable typecasts the variable as an integer, usefull when
the SQL is returning numbers as strings
switch ((int) $r['id_respuesta']) {
case 1:
$type='excelente';
break;
case 2:
$type='bueno';
break;;
case 3:
$type='regular';
break;
case 4:
$type='malo';
break;
case 5:
$type='si';
break;
case 6:
$type='no';
break;
case 7:
$type='no respondio';
break;
case 8:
$type = 'recomendación';
break;
case 9:
$type = 'anuncio de revista';
break;
case 10:
$type = 'letrero carretera';
break;
case 11:
$type = 'google';
break;
case 12:
$type = 'directo al hotel';
break;
case 13:
$type = 'llamada al 800';
break;
case 14:
$type = 'sitio web del hotel';
break;
case 15:
$type = 'sitio web de otros';
break;
case 16:
$type = 'agencia de viajes';
break;
case 17:
$type = 'otros';
break;
default:
die('{"error":"Error in SQL query: unknown \'id_respuesta\'"}');
}
$temp[] = array('v' => $type." =".$r['cnt']);
$temp[] = array('v' => (int) $r['cnt']);
$temp[] = array('v' => (int) $r['id_aspecto']);
$rows[] = array('c' => $temp);
}
$table['rows'] = $rows;
$jsonTable = json_encode($table);
header('Cache-Control: no-cache, must-revalidate');
header('Expires: Mon, 26 Jul 1997 05:00:00 GTM');
header('Content-type: application/json');
echo $jsonTable;
?>
--
You received this message because you are subscribed to the Google Groups
"Google Visualization API" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-visualization-api?hl=en.