Titanium using JSON Parsing
===

I am trying to retrieve data from PHPMyAdmin and trying to display the data to the picker change....
Here is my code
     var currentWin = Ti.UI.currentWindow;
 
     var sendit = Ti.Network.createHTTPClient();
     sendit.open('GET', 'http://localhost/mobileapp/productread.php');
     sendit.send();
      sendit.onload = function(){
     var json = JSON.parse(this.responseText);
 
     var json = json.mobile_product;
 
     var picker = Ti.UI.createPicker();
      // turn on the selection indicator (off by default)
     picker.selectionIndicator = true;
 
     var data = [];
      var pos;
     data.push (Ti.UI.createPickerRow({title:''+ json[pos].product_name +      '',custom_item:'b'}));
     }
     picker.add(data);
     currentWin.add(picker);
 
 
 
    //var rw = db.execute("SELECT product_name, SUM(product_quantity)FROM mobile_product   GROUP BY product_name");
 
    picker.addEventListener('change', function(e){
     var sendit = Ti.Network.createHTTPClient();
    sendit.open('GET', 'http://localhost/mobileapp/orderread.php');
    sendit.send();
 
 
    sendit.onload = function(){
    var json = JSON.parse(this.responseText);
 
    var json = json.mobile_product;
     var pos;
    var product_name = json[e.rowIndex];
     for (pos=0; pos < json.length; pos++) {
 
    alert(''+json[pos].orders + '');
    }
    }
    })
     }
Here when i change the picker, alert appears with all the values of the column(orders) for a single change... If I change the picker to the next, again the alert appears for all the datas in the column.. For example, If i have 10 values in the column(order), and if I change the picker valus, the alert appears 10 times with 10 values..
I want to display the value from the column according to the change in the picker....
I have retrieved data(product_name) from PHPMyAdmin for the picker... When I change the picker, i want the values for that particular names to be displayed....
I am using the Query
SELECT SUM(product_quantity) As orders FROM mobile_product GROUP BY product_name
in the PHP file..
My PHP file is
    <?php
    //cust-mysql-123-04
    $link = mysql_connect('localhost', 'root', '');
     if (!$link) {
    die('Not connected : ' . mysql_error());
    }
    // make foo the current db
    $db_selected = mysql_select_db('mobileapp', $link);
    if (!$db_selected) {
    die ('Can\'t use  : ' . mysql_error());
    }
    // Set the default namespace to utf8
    mysql_query("SET NAMES 'utf8'");
    if($result = mysql_query("SELECT SUM(product_quantity) As orders FROM mobile_product     GROUP BY product_name")) {
    //echo mysql_num_rows($result);
      while ($row=mysql_fetch_array($result)) {
       // $json.= "<li>".$row['first_name']."</li>";
        $json[]=array(
        'orders'=>$row['orders']
        );
     }
    }
    echo json_encode(array( 'mobile_product'  =>   $json ));
 
    mysql_close();
    ?>

