tags:

views:

113

answers:

2
function showFields($selClient) 
    {
     $result = mysql_query("SELECT * FROM project WHERE projectid = $selClient");
     $values = array();
     while($row = mysql_fetch_array($result)) 
     {
      $values[] = array($row['clientname'],$row['prospect'],$row['salesperson']);
     }
     return $values;

  }

When i return the values to Flex, i am not able catch individual elements. When i trace i get all values stored in a single array...

I am slightly confused...,.

var editField:Array = event.result as Array; 
     Alert.show(editField[0]);

This returns all the values in the Array, instead of the 0th element.

+1  A: 

you could do: Alert.show(editField[0][0]);

if i understand it correctly...

you need to iterate over two arrays (two levels)

dusoft
yea... when i try to print it in flex, i dont get individual values..
+1  A: 

Also, if you are only returning specific columns, why select them all? This will function will return the same data and as it only selects what you need, will be faster. In this case the select is so simple that the time difference will be virtually 0, but it's a good habit to get into for when your db queries start getting more complex.

function showFields($selClient) 
{
    $result = mysql_query("SELECT clientname, prospect, salesperson FROM project WHERE projectid = $selClient");
    $values = array();
    while($row = mysql_fetch_array($result)) 
    {
        $values[] = $row;
    }
    return $values;
}
MatW