Reading data in to ComboBox from PHP page. (corrections)

June 21, 2008

Actually I made this post long back but the post had some corrections so iam making those here. It was actually suggested by a a person called John that he didn’t get the post clearly and insisted to make another one for newbies. So I decided to make a clear one here with complete code.

The post missed one line as it was pointed out in the comment , the line is to send the HttpService you are using to get the Data.

Flex code :

<?xml version=”1.0″ encoding=”utf-8″?>

<mx:Application xmlns:mx=”http://www.adobe.com/2006/mxml” layout=”absolute

creationComplete=”projectsSrv.send();”>

<mx:HTTPService

id=”projectsSrv

url=”new.xml

useProxy=”false” method=”POST>

</mx:HTTPService>

<mx:ComboBox

id=”cmb1” x=”152” y=”53

dataProvider=”{projectsSrv.lastResult.records.record}

labelField=”data></mx:ComboBox>

</mx:Application>

PHP code or XML file code:

<records>

<record data=”1″ label=”Corco”/>

<record data=”5″ label=”Shell Crop Protection”/>

<record data=”7″ label=”Olin McIntosh”/>

<record data=”9″ label=”Crab Orchard”/>

<record data=”10″ label=”Shell Oil Del Amo”/>

<record data=”11″ label=”AIG South Jersey Gas”/>

<record data=”12″ label=”Husch &amp; Eppenberger Litigation-New York”/>

<record data=”22″ label=”Shell Sturbridge”/><record data=”24″ label=”Shell Southington”/>

<record data=”26″ label=”Olin Personal Injury”/>

</records>

You can send data in this format or get it from the XML file, here its from XML file “new.xml”.you can even echo these lines in PHP and a file as new.php.

As you can see the difference here, from that post is, here iam using the line creationComplete=”projectsSrv.send();” in the Application tag to send the service and read the data.

Now it will work fine and comments are welcome !


Good PHP tutorials at my blog.

January 25, 2008

Even though the help file at php has many good examples and explanations ,some of the users still search the web for php tutorials ,so for them i give the tutorials which were prepared by me and my team members ,and these are really good ones, its brief and quick.

Basics/Musics of PHP..

“fun”ctions and “class”es in PHP

strings Part1 PHP

strings Part2 PHP

URL functions PHP

click the above links to navigate and download..


To join Array elements into a String in PHP.

January 7, 2008

Here its the paradox of explode() function and the function name is implode().

using the function:

$str=array(’kumar’,'gandhi’,'flexonblog’);

now i want to join the array elements into one string with’-’ as separated ,so to do this we have to write the line..

$newstr=implode(”-” ,$str);

Now if we print the string string ..

echo $newstr;

The Ouput: kumar-gandhi-flexonblog

its the reverse of the function explode().


split a string into array of strings formed by the string delimiter.

January 7, 2008

If i have a string like :

$str=”D:/newfolder/kumar/gandhi”;

Then to seperate the string $str with ‘/’ as delemiter we have to use the function available explode() in PHP.

Its very usefull when we are sending group of data from Flex and splitting it using the function in PHP explode().For our calculation.

using the function :

$str1=explode(”/”,$str);

now using the string $str1 as array which contains the splitted string..

for($i=0;$i<=$str1.length;$i++)

{

echo $str1[$i].”</br>”;

}

Now this will print the string as –>

D:

newfolder

kumar

gandhi

Hence the usage of explode() function..


mailing in PHP using mail function..

January 5, 2008

First the syntax of the mail function is ..

mail($to$subject$message$headers);

$to-> to mail ID

$subject->the sub of the mail.

$message->the actual text message to send to the $to.

$headers->can contain the info regarding from or purpose..

and finally define the variables ..

$to=’kumargandhi30@gmail.com’;

$subject=’How are U my Friend?’;

$message=’hi kumar’;

$headers=’From:me@gmail.com’;

and now call the function.. mail($to$subject$message$headers);

this will send a mail to the mentioned..


Sending data from PHP as XML.

January 5, 2008

The basic XML data looks like –

<product>

<pname>mouse</product>

<cost>100</cost>

</product>

so this in PHP pages looks like–

echo “<product>”;

echo “<pname>”mouse”</pname>”;

echo “<cost>”100″</cost>”;

echo “</product>”;

here iam using echo statement of PHP to represent data as XML and this page is called in an HTTPSERVICE.