Dear friends,
                  i doing a project where i selected a city name from
comboBox that selectedIndex has to sent through GET method to the php
file, for that selectedIndex the php file should retrive 
corresponding
data from a dataBase table.................but my code was not
working .Here is my code, if any find mistake in my code pls let me
knw .Otherwise if any body having sample code send it to me.

Code for change in comboBox:

 <mx:ComboBox id="citycombo" prompt="Select An Area" x="10" y="176"
width="194" change="searchCombo()"/>

<mx:HTTPService id="srv2" url="http://localhost/HomeLocator-1/
dataGrid.php" result="datagridResHandler(event)"   method="GET"/>

private function searchCombo():void
{
        var selectedID:int;
        var ID:int;
        selectedID=citycombo.selectedIndex;
        ID=selectedID+1;
        srv1.send(ID);

}

the output  has to be diplayed in this data grid,the code fr 
dataGrid:

private function datagridResHandler(event:ResultEvent):void
{
        arr1=event.result.data.id as ArrayCollection;
        for(var i:int=0;i<=arr1.length;i++)
        {
                var obj:Object=new Object;
                obj.prix=event.result.data.prix[i];
                obj.surface=event.result.data.surface[i];
                obj.nb_pieces=event.result.data.nb_pieces[i];
                obj.nb_chambres=event.result.data.nb_chambres[i];
                arr.addItem(obj);
        }
        dg.dataProvider=arr;

}

php file code:

<?php
$db_name = "homelocator";
$link = mysql_connect('localhost', "root", "admin") or die("Could not
connect to server!");
$table_name = 'jos_ordimmo_annonces';

$select_db = mysql_select_db($db_name, $link);
$ID=$_REQUEST['ID'];
$query = 'SELECT * FROM jos_ordimmo_annonces WHERE villeid='ID'';
$result = mysql_query($query, $link) or die("Could not complete
database query");

$num = mysql_num_rows($result);
while ($row = mysql_fetch_array($result))
if ($num != 0) {
$file= fopen("results.xml" , "w");
$_xml ="<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\r\n";
$_xml .=" <data from=\"" . $row[from] . "\" to=\"" . $row
[to] . "\">\r
\n";

while ($row = mysql_fetch_array($result)) {

$_xml .=" <id>" . $row[id] . "</id>\r\n";
$_xml .=" <prix>" . $row[prix] . "</prix>\r\n";
$_xml .=" <surface>" . $row[surface] . "</surface>\r\n";
$_xml .=" <nb_pieces>" . $row[nb_pieces] . "</nb_pieces>\r\n";
$_xml .=" <nb_chambres>" . $row[nb_chambres] . "</nb_chambres>\r\n";
$_xml .=" <pub_longue>" . $row[pub_longue] . "</pub_longue>\r\n";

}

$_xml .=" </data>";
fwrite($file, $_xml); //fwrite -- Binary-safe file write
fclose($file); //fclose -- Closes an open file pointer
echo $_xml;
}

else {
echo "No Records found";
}

?>
Thanks in Advance

Reply via email to