php to JavaScript variable transfer
<p>I'm not very familiar with JavaScript but for a project that I'm working on, I need to draw a graph using some input from the db. Can you help me out with the transfer of the php values to the javascript. I just want to draw a pie chart using the data from the db. </p>

<pre><code>&lt;div id="pie" style="width:250px;height:250px;"&gt;

    &lt;?php 
        $k=0; 
        if (isset($distrib)){
            foreach($distrib as $row){
              echo $distrib[$k]['lang'];
              echo $distrib[$k]['NumArt'];
               $k++;
            }
        }
    ?&gt;​

    &lt;script class="code" type="text/javascript"&gt;
        $(document).ready(function() {
            var data = [];
            var plot1 = jQuery.jqplot('pie', [data], {
                seriesDefaults: {
                    // Make this a pie chart.
                    renderer: jQuery.jqplot.PieRenderer,
                    rendererOptions: {
                        // Put data labels on the pie slices.
                        // By default, labels show the percentage of the slice.
                        showDataLabels: true
                    }
                },
                legend: {
                    show: false,
                    location: 'e'
                }
            });
        });​
    &lt;/script&gt;
</code></pre>

<hr>

<p>EDIT</p>

<p>I'm still struggling with this issue. These js charts are killing me.</p>

<p>So here is an additional question that will hopefully end my misery </p>

<pre><code>                            if (isset($distrib)){
                                foreach($distrib as $row){
                                  $p[] = $distrib[$k]['langName'];
                                  $s[] = $distrib[$k]['lang'];
                                  $q[] = $distrib[$k]['NumArt'];
                                   $k++;
                                }}  
                            ?&gt;&lt;?php $c = array_combine($p, $q); ?&gt;

                        &lt;script class="code" type="text/javascript"&gt;$(document).ready(function(){


                                    &lt;?php echo "var s1 = [".implode($c, ",")."];" ?&gt;
                                var plot3 = $.jqplot('pie',  [s1], {
</code></pre>

<p>Basically at the moment the chart is printing out numArt, but it does not print the langName which i want. Lang name stores languages in their native alphabet which means anything from arabic to Zulu. I tried using JSON with no success (i totally lack knowledge in that area). My d/encoding was messed up so I left that path.</p>

<p>My goal is to render a chart which has the language's name and the amount of articles for that language.</p>

<p>So here is the print_r from<br>
$p </p>

<p>Array ( [0] => none [1] => Catal [2] => français [3] => Malti [4] => português [5] => Kiswahili [6] => isiZulu [7] => English )</p>

<p>and $q 
Array ( [0] => 1 [1] => 1 [2] => 1 [3] => 2 [4] => 1 [5] => 1 [6] => 1 [7] => 1 )</p>

<p>and the combined $c
Array ( [none] => 1 [Catal] => 1 [français] => 1 [Malti] => 2 [português] => 1 [Kiswahili] => 1 [isiZulu] => 1 [English] => 1 )</p>

<p>In the end I need s1 to be something along these lines </p>

<p>[['none',1],['français',1],['Malti',1]]</p>

<hr>
