Sherif Abdou:

Thank you very much for your timely answer!
I'm a beginner, it is my first practice.
I get confused.....I will tell you what I want to do.

There are 4 classes (class 1, class 2, class 3 and class 4) in my
example,  and there are about 50 students in each class.
I want to display the students' name in the ComboBox when I select a
class:
http://farm4.static.flickr.com/3181/2563857208_648f54fab6_o.gif
<a href="http://www.flickr.com/photos/xybeta/2563857208/";
title="combobox by xaero, on Flickr"><img
src="http://farm4.static.flickr.com/3181/2563857208_648f54fab6_o.gif";
width="307" height="204" alt="combobox" /></a>

The test.mxml:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml";
layout="absolute">
     <mx:Script>
         <![CDATA[

             import flash.net.Responder;
             import mx.controls.Alert;

             public var gateway:NetConnection;

             //The first ComboBox's dataProvider that display the
classes' name
             [Bindable]
             public var atClassProvider:Array = new Array(
                 {label:"Please Choose Your Class", data:""},
                 {label:"Class 1",data:"1"},
                 {label:"Class 2",data:"2"},
                 {label:"Class 3",data:"3"},
                 {label:"Class 4",data:"4"});

             //The second ComboBox's dataProvider that display the
students' name
             [Bindable]
             public var ssProvider:Array;

             public function onInit():void
             {
                 gateway = new NetConnection();
                
gateway.connect("../php_ria_sdk_by_adobe/libraries/amfphp/gateway.php");
             }
             private function changeHandler(event:Event):void
             {
                 var atClass:Object = new Object();
                 atClass.atcls =
ComboBox(event.target).selectedItem.data;
                 //Alert.show(atClass["atcls"],"ALERT");
                 gateway.call("Cys.getStudents", new Responder(getResult,
onFault),atClass);
             }
             public function getResult(result:Array):void
             {
                 ssProvider = result;
             }
             public function onFault(fault:String ):void
             {
                 //errorMsg = fault;
                 trace(fault);
             }
         ]]>
     </mx:Script>
     <mx:ComboBox x="83" y="96" id="atclass"
change="changeHandler(event);"
dataProvider="{atClassProvider}"></mx:ComboBox>
     <mx:ComboBox x="83" y="160" id="ssname"
dataProvider="{ssProvider}"></mx:ComboBox>

</mx:Application>

The Cys.php under amfphp/services:
<?php
Define('DATABASE_SERVER', 'localhost');
Define('DATABASE_USERNAME', 'root');
Define('DATABASE_PASSWORD', '123456');
Define('DATABASE_NAME', 'cys');

class Cys
{
     var $mysqli;

     function Cys()
     {
         # Connect to MySQL database....
         $this->mysqli = new mysqli(DATABASE_SERVER, DATABASE_USERNAME,
DATABASE_PASSWORD, DATABASE_NAME);
         # Check MySQL connection
         if (mysqli_connect_errno()) {
             # Dont use die (Fatal Error), return useful info to the
client
             trigger_error("AMFPHP Remoting class could not connect: " .
mysqli_connect_error());
         }
     }
     function getStudents($atClass) {
         # Return a list of all the students
        
$atcls=$this->mysqli->real_escape_string(trim($atClass['atcls']));
         $sql = "SELECT * from students where atclass = '".$atcls."'";
         if ([EMAIL PROTECTED]>mysqli->query($sql)) {
             $errno=$this->mysqli->errno;
             $this->mysqli->close();
             trigger_error("AMFPHP Remoting class database SELECT query
error: " . $errno);
         }
         while ($row = $result->fetch_assoc()) {
             $user_array[] = $row;
         }
         return($user_array);
     }
}
?>

The sample above can't work properly.
I think, it because the returned array $user_array can't be populated
into the ComboBox properly... Am I right?
How to correct it?
Thank you for taking so much time in my problems!

--- In [email protected], Sherif Abdou <[EMAIL PROTECTED]> wrote:
>
> well i do not know how advanced you are but i am assuming you did not
do this, put a result handler then
> private function popCombo(event:ResultEvent):void
> {
>     var arrayCollection:ArrayCollection = event.result.whatever you
need to get todwn then
>     myComboBox.dataProvider = arrayCollection;
> }
>
>

Reply via email to