Adam,

It depends what you want to do, but the easiest solution would be to target
a data format specified at
https://developers.google.com/chart/interactive/docs/datatables_dataviews
In particular, you might want to look at the arrays that can be fed
directly into arrayToDataTable() - the example on that page should show
what it needs to look like.

What I've done in this case is to take the associative array in PHP and
iterate over all the keys. If the key is a number (tested by PHP's
is_numeric() function), then throw it out. Otherwise, create a new array
row with values being the key and value from the associative array and add
this to the array to return.

Your needs may vary, but this has worked for the things I've tried to do.

Allen

On Sun, Jul 8, 2012 at 6:54 AM, Adam Hardarson <[email protected]>wrote:

> Ok, but I havn't gotten anywhere really... :-/
>
> ------------------------------------------------------------------
> if(!empty($_POST['first']) && !empty($_POST['second']) &&
> intval($_POST['first']) !== intval($_POST['second'])){
>     $first = $_POST['first'];
>     $second = $_POST['second'];
>     $ord = ($second <= $first) ? 'DESC' : '';
>     $r = mysql_query("SELECT * FROM MCI WHERE Id = $first OR Id = $second
> ORDER BY Id $ord");
>     if(mysql_num_rows($r) == 2){
>         while($d = mysql_fetch_array($r)){
>             $arr[] = $d;
>         }
>         $output = createHTML($arr);
>     }else{
>         $output = "The values must be different and exist in the list. " .
> $output;
>     }
> }
>
>     $first = $arr[0];
>     $second = $arr[1];
>
> $firstdata = json_encode($arr[0]);
> $seconddata = json_encode($arr[1]);
> ------------------------------------------------------------------
>
> My print json looks like
> this 
> {"0":"7","Id":"7","1":"test","Foretag":"test","2":"44","Variabel_namn_4":"44","3":"34","Variabel_namn_5":"34","4":"64","Variabel_namn_6":"64"}
>
> So I have to format it the right way but I can't figure out how...
>
> If I want to show a simple bar chart with these
> columns "Variabel_namn_5":"34","Variabel_namn_6":"64" How should I proceed?
>
> Many thanks for taking time helping me out! :)
>
> Cheers
> Adam
>
>
>  --
> 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/-/atXAy-CU7aIJ.
>
> 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.
>

-- 
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