i have this my friend .. but look.. somethimes the error that shows me as a
message is this :{"error":"Error in SQL query: unknown 'id_respuesta'"} and
sometimes the just is a message like this
 
{"cols":[{"label":"Type","type":"string"},{"label":"Count","type":"number"}],"rows":[]}


These dates are valid in my sql query:

 select b.id_respuesta, COUNT(b.id_respuesta) AS cnt FROM huesped a,
rompe_encuesta b
 WHERE
 b.id_huesped = a.id_huesped AND
 b.id_aspecto = 1 AND
 b.id_respuesta >= 8 AND
 b.id_respuesta <= 11 AND
 a.fecha BETWEEN '2012-12-01' AND '2012-12-10' GROUP BY b.id_respuesta;
 this query is in mysql and this shows me this :

+--------------+-----+
| id_respuesta | cnt |
+--------------+-----+
|            8    |        2 |
|            9    |        1 |
|           10   |       1 |
|           11   |       2 |

but When I enter the same date in my interface this is the result :
{"error":"Error
in SQL query: unknown 'id_respuesta'"

u know I have only answer that people responded between these two
dates  BETWEEN '2012-12-01' AND '2012-12-10 and for

example when i put another date like 2012-11-01 and 2012-12-01 the message
witch shows me is this . this is the result :

{"cols":[{"label":"Type","type":"string"},{"label":"Count","type":"number"}],"rows":[]}




this is my file php
<?php
$var1="$_POST[fecha1]";

$var2= "$_POST[fecha2]";

$server="localhost";
$username="root";
$password="chrystopher";
$databasename="encuestasavandaro";

$con = mysql_connect($server,$username,$password) or die ('Error connecting
to server');
mysql_select_db($databasename,$con);

$query = "SELECT b.id_respuesta, COUNT(b.id_respuesta) AS cnt
FROM huesped a, rompe_encuesta b
WHERE
b.id_huesped = a.id_huesped AND
b.id_aspecto = 1 AND
b.id_respuesta >= 8 AND
b.id_respuesta <= 11 AND
a.fecha BETWEEN '$var1' AND '$var2'
GROUP BY b.id_respuesta;";


$table = array();

$table['cols']=array(
array('label' => 'Type' , 'type' => 'string'),
array('label' => 'Count' , 'type' => 'number')
);

$rows = array();
 if (!mysql_query($query,$con))
  {
  die('Error: ' . mysql_error());
  }else{
      $sqlquery= mysql_query($query);
while($r = mysql_fetch_assoc($sqlquery)){
    $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 8:
$type = 'word of mouth recomendation';
break;
case 9:
$type = 'magazine advertisement';
break;
case 10:
$type = 'roadside advertisement';
break;
default:
die('{"error":"Error in SQL query: unknown \'id_respuesta\'"}');
}

    $temp[] = array('v' => $type);
    $temp[] = array('v' => (int) $r['cnt']);
    $rows[] = array('c' => $temp);
}
  }
$table['rows'] = $rows;

$jsonTable = json_encode($table);
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.

Reply via email to