Hi, i have still problem with post data... in attach my files. when i set "date from" and click submit, files "goo2.php" generates correct array, but this array is not import back to "index.php". Please could somebody help me? :(
W dniu czwartek, 13 grudnia 2012 08:22:00 UTC+1 użytkownik Chrystopher
Medina napisał:
>
>
>
> i didn´t understand very well ... excuse me. but
> this is my new json array :
>
> {"cols":[{"label":"Type","type":"string"},{"label":"Count","type":"number"},{"label":"Aspecto","type":"number"}],"rows":[{"c":[{"v":"excelent"},{"v":1}]},{"c":[{"v":"good"},{"v":2}]},{"c":[{"v":"fair"},{"v":1}]},{"c":[{"v":"poor"},{"v":1}]},{"c":[{"v":"word
>
> of mouth recomendation"},{"v":3}]},{"c":[{"v":"magazine
> advertisement"},{"v":1}]},{"c":[{"v":"roadside
> advertisement"},{"v":1}]},{"c":[{"v":"google"},{"v":3}]}]}.
>
> this is my php file:
>
> <?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,
> b.id_aspecto
> 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)
> OR
> (b.id_aspecto = 2 AND b.id_respuesta >= 1 AND b.id_respuesta <= 4))
> AND
> a.fecha BETWEEN '2012-12-01' AND '2012-12-12'
> GROUP BY b.id_respuesta;";
>
>
> $table = array();
>
> $table['cols']=array(
> array('label' => 'Type' , 'type' => 'string'),
> array('label' => 'Count' , 'type' => 'number'),
> array('label' => 'Aspecto', '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 1:
> $type='excelent';
> break;
> case 2:
> $type='good';
> break;;
> case 3:
> $type='fair';
> break;
> case 4:
> $type='poor';
> break;
>
> 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 view this discussion on the web visit
https://groups.google.com/d/msg/google-visualization-api/-/7L_MKPBaM6cJ.
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.
<<attachment: index.php>>
<<attachment: goo2.php>>
