yes u are right.... my new result is this :

{"cols":[{"label":"Type","type":"string"},{"label":"Count","type":"number"}],"rows":[{"c":[{"v":"word
of mouth recomendation"},{"v":2}]},{"c":[{"v":"magazine
advertisement"},{"v":1}]},{"c":[{"v":"roadside
advertisement"},{"v":1}]},{"c":[{"v":"google"},{"v":2}]}]}

yes my friend i need 4 answers .is for that i add  this :

$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 // this
a.fecha BETWEEN '$var1' AND '$var2'
GROUP BY b.id_respuesta;";

I have modified the code like this:
  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;
                    case 11:
$type = 'google';
break;
                    default:
die('{"error":"Error in SQL query: unknown \'id_respuesta\'"}');
 }


and this is all my file php. Check it please.


<?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;
                    case 11:
$type = 'google';
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