PROBLEM: Get list of category from database

1. create php file to query database (lisaKategorija.php)
--------------------------------------
<?php
define( "DATABASE_SERVER", "localhost" );
define( "DATABASE_USERNAME", "xxxx" );
define( "DATABASE_PASSWORD", "xxxx" );
define( "DATABASE_NAME", "portal" );

//connect to the database.
$mysql = mysql_connect(DATABASE_SERVER, DATABASE_USERNAME,
DATABASE_PASSWORD);

mysql_select_db( DATABASE_NAME );


$Query = "SELECT Ime from kategorije"; // select atribute "Ime" from
table "kategorije
$Result = mysql_query( $Query );

$nizKategorija = array();

while ($row = mysql_fetch_assoc($Result)) {
   $nizKategorija[]=$row['Ime'];

}


foreach ($nizKategorija as $v) {
echo "$v,";                                        // this print value
variable $v seperated by coma
}


mysql_free_result($Result);
?>

---------------------------------------------------------

2. create HTTPService to call this php file

--------------------------------------------------------
<mx:HTTPService id="listaKategorija"
                                useProxy="false"
                                
url="http://localhost/skripte/listaKategorija.php";
                                result="kategorijeHandler(event)"
                                resultFormat="text"
                                showBusyCursor="true"
                                 />
---------------------------------------------------------
As you can see this HTTPService call listaKategorija.php end on result
in call kategorijeHandler(event)\
Now we must define this function

3. kategorijeHandler code

------------------------------------------------
        private function kategorijeHandler(kat:ResultEvent):void
                {
                var string:String = kat.result.toString();
                var meniji:Array = string.split(",");
                        selektorKategorije.dataProvider = meniji;   // I bind
component comboBox  with id=selektorKategorije with content of
variable (Array) called meniji

                }

--------------------------------------------------

4. define component ComboBox

<mx:ComboBox x="69" y="39" id="selektorKategorije" ></mx:ComboBox>

If any one have questions about this I will answer, this is much
faster, yes I could create xml from database query but this is one
step faster, I think.

Thx for great lead dinesh kumar

Happy flexing

--

You received this message because you are subscribed to the Google Groups "Flex 
India Community" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/flex_india?hl=en.


Reply via email to