title: Google chart for each row of MySqL table
body: <p>New PHP user here. I have a database that looks like this:</p>
  
  <pre> <b>id    name    day1    day2    day3      day4       day5 </b></pre>
  
  <pre><code>  1    nam1     5       9       15        50         45
    2    nam2     51      12      54        78         56
    3    nam3     12      145     78        49         58
  </code></pre>
  
  <p>The database contains thousands of users. Each number in the table represents the amount of daily activities per user. We need a table which looks like this </p>
  
  <blockquote>
    <p></p>
  </blockquote>
  
  <pre> <b>id    name    day1    day2    day3      day4       day5     chart</b></pre>
  
  <pre><code>  1    nam1     5       9       15        50         45
    2    nam2     51      12      54        78         56
    3    nam3     12      145     78        49         58
  </code></pre>
  
  <p>We want to draw a google line chart in the last column for each user. This is the code to generate the chart:</p>
  
  <pre><code>    &lt;?php
  
      $result = mysqli_query($c,"SELECT * from users limit 100");
  
      $row = mysqli_fetch_array($result); 
  
      $d1=$row['day1']; $d2=$row['day2']; $d3=$row['day3']; $d4=$row['day4']; $d5=$row['day5']; 
  
      //// that's the data that get loaded into Google Charts(no axis label) ////
  
      $data="[['','day'],['',".$d1."],['', ".$d2."],['', ".$d3. "],['', ".$d4."],['', ".$d5. "]]";   
       ?&gt;
      &lt;html&gt;
      &lt;head&gt; 
      &lt;script type="text/javascript" src="https://www.google.com/jsapi"&gt;&lt;/script&gt;
      &lt;script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"&gt;&lt;/script&gt;
      &lt;script type="text/javascript"&gt;
       google.load("visualization", "1", {packages:["corechart"]});
       google.setOnLoadCallback(drawChart);
       function drawChart() {
       var data = google.visualization.arrayToDataTable(&lt;?php echo $data ?&gt;);
       var options = {
                        title: 'User Activities',
                            curveType: 'function',
                            width:200,
                            height:150,
                            legend: 'none'
  
                      };
  
  var chart = new google.visualization.LineChart(document.getElementById('chart_div'));
                      chart.draw(data, options);
                    }
                  &lt;/script&gt; 
                 &lt;/head&gt;
              &lt;body&gt;
              &lt;?php echo "&lt;table border='1'&gt;
              &lt;tr&gt;
              &lt;th&gt;id&lt;/th&gt;
              &lt;th&gt;name&lt;/th&gt;
              &lt;th&gt;charts&lt;/th&gt;
              &lt;/tr&gt;";
  
              while($row = mysqli_fetch_array($result)) {
  
                echo "&lt;tr&gt;";
                 echo "&lt;td&gt;" . $row['id'] . "&lt;/td&gt;";
                  echo "&lt;td&gt;" . $row['name'] . "&lt;/td&gt;";
                    echo "&lt;td&gt; 
                  &lt;div id=\"chart_div\" style=\"width:200; height:150\"&gt;&lt;/div&gt;&lt;/td&gt;";
  
                echo "&lt;/tr&gt;";
              }
              echo "&lt;/table&gt;"; ?&gt;
              &lt;/body&gt;
              &lt;/html&gt;
  </code></pre>
  
  <p>This code generates only one chart for user id=2. The first user, and the other users are ignored. How do you get a chart for each row? Thanks four help.</p>