Salve a tutti,
come da oggetto dovrei estrarre i dati da una tabella clienti--> colonna "nazioni", contare ciascuna nazione quante volte compare ed avere un risultato tipo

Italia 2
Brasile 3
Inghilterra 4
......

cioè inviarle a due variabili da dare in pasto a google chart per l'elaborazione grafica finale.
Sono riuscito a collegare chart al DB ma vuole una tabella con due colonne separate una per il nome nazione e una per i dati, ma la mia struttura è diversa è non posso cambiarla.
Qualcuno può aiutarmi a capire quale istruzione posso utilizzare per estrarre e contare i dati?
Questo il codice in uso attualmente e funziona bene se lo collego appunto ad una tabella con due colonne separate per i dati.
Codice PHP:
/* Establish the database connection */  $mysqli = new mysqli($DB_HOST$DB_USER$DB_PASS$DB_NAME);
  if (
mysqli_connect_errno()) {    printf("Connect failed: %s\n"mysqli_connect_error());    exit();  }
   
/* select all the weekly tasks from the table googlechart */           $result $mysqli->query('SELECT * FROM nations');
  
/*      ---------------------------      example data: Table (googlechart)      --------------------------      Nazioni     Visite      Italia           30      Brasile         10      Inghilterra    40      Francia         20         */
  
$rows = array();  $table = array();  $table['cols'] = array(
    
// Labels for your chart, these represent the column titles.    /*         note that one column is in "string" format and another one is in "number" format         as pie chart only required "numbers" for calculating percentage         and string will be used for Slice title    */
    
array('label' => 'Nazioni''type' => 'string'),    array('label' => 'Visite''type' => 'number')
);    
/* Extract the information from $result */    foreach($result as $r) {
      
$temp = array();
      
// The following line will be used to slice the Pie chart
      
$temp[] = array('v' => (string) $r['nazione']); 
      
// Values of the each slice
      
$temp[] = array('v' => (int) $r['visite']);       $rows[] = array('c' => $temp);    }
$table['rows'] = $rows;
// convert data into JSON format$jsonTable = json_encode($table);//echo $jsonTable; 
Spero di essere stato chiaro nella spiegazione.
Grazie