title: PHP array to Graph
body: <p>First of all, I have a stores table as follows :</p>
  
  <p><strong>Table Name : stores</strong></p>
  
  <pre><code>id |name
  1  | M1
  2  | M2
  </code></pre>
  
  <p>And Each store is considered as a table which have its own items, selling price and qty as follows</p>
  
  <p><strong>Table Name : M1</strong></p>
  
  <pre><code>id | item | qty | sell_price
  1  | z1   | 12  | 5.00
  2  | z2   | 15  | 6.00
  </code></pre>
  
  <p><strong>Table Name : M2</strong></p>
  
  <pre><code>id | item | qty | sell_price
  1  | z1   | 12  | 5.00
  2  | z5   | 25  | 12.00
  3  | z6   | 5   | 7.00
  </code></pre>
  
  <p>Now I want to create a bar graph by which I need to see Each store its Total selling price ( <code>SUM(sell_price)</code> ) , as follows :</p>
  
  <pre><code>Y-axis ( Total Sell_price )
   30|          _____
   25|  ____   |     |
   20| |    |  |     |
   15| |    |  |     |
    0|_|____|__|_____|________ X - axis (Store Name )
         M1      M2
  </code></pre>
  
  <p>I've created the PHP code as follows :</p>
  
  <pre><code>$query1 = "SELECT name from stores";
  $result1 = mysql_query($query1);
  if(!mysql_num_rows($result1)&gt;0){
      echo "&lt;center&gt;&lt;font color=red&gt;No Stores Found !&lt;/font&gt;&lt;/center&gt;";   
  }
  else{
  while ($row1 = mysql_fetch_assoc($result1)){
  $query = "SELECT *,SUM(sell_price) FROM {$row1['name']}";
  $result = mysql_query($query);
  $row = mysql_fetch_assoc($result);
  
  $store[]= $row1['name'];
  $sale[] = $row['SUM(sell_price)'];
  
  }
  }
  </code></pre>
  
  <p>Bar Graph JavaScript - <strong>Please Note</strong> <code>var s1</code> and <code>var ticks</code> are the ones needed to be changed and collects array from the above PHP loop</p>
  
  <pre><code>&lt;script class="code" type="text/javascript"&gt;$(document).ready(function(){
          $.jqplot.config.enablePlugins = true;
           var s1 = [200, 888, 645, 1044];
           var ticks = ['M1','M7','M9','M10'];
  
  
          plot1 = $.jqplot('chart1', [s1], {
              // Only animate if we're not using excanvas (not in IE 7 or IE 8)..
              animate: !$.jqplot.use_excanvas,
              seriesDefaults:{
                  renderer:$.jqplot.BarRenderer,
                  pointLabels: { show: true }
              },
              axes: {
                  xaxis: {
                      renderer: $.jqplot.CategoryAxisRenderer,
                      ticks: ticks
                  }
              },
              highlighter: { show: false }
          });
  
          $('#chart1').bind('jqplotDataClick', 
              function (ev, seriesIndex, pointIndex, data) {
                  $('#info1').html('series: '+seriesIndex+', point: '+pointIndex+', data: '+data);
              }
          );
      });&lt;/script&gt;
  </code></pre>
  
  <p>Now as you can see, I've created an array <code>$store</code> and <code>$sale</code> - Not sure if its a correct array because i'm not too familiar with arrays. However I need to find how can I assign the array values to javascript <strong>vars</strong> (<strong>s1</strong> and <strong>ticks</strong>) accordingly.</p>