I am having a strange problem in populating datagrid..
I am able to populate the datagrid if there are more than 1 records.
However if there is just 1 record it is not displayed in the
datagrid.
After checking I found out that the call to database and retrieval
of records are working fine. There is problem with populating
datagrid only if only single record is retrieved.
any suggestion?? what is going wrong
Please find below the relevant code snippets...
<mx:Script>
<![CDATA[
function queryByName(){
customer_srv.send({query_type:'getcustomer', custfname:
txtfname.text, custlname: txtlname.text});
}
]]>
</mx:Script>
<mx:HTTPService id="customer_srv" url="xxxxxxx.php"
fault="faultHandler(event.fault.faultstring,
event.fault.faultcode)"
result="resultHandler(event)"
method="POST" showBusyCursor="true" useProxy="false" />
<mx:Panel id ="adminpanel" width="877" horizontalAlign="center">
<mx:Grid>
<mx:GridRow>
<mx:GridItem>
<mx:Label text="First Name" />
</mx:GridItem>
<mx:GridItem>
<mx:Label text="Last Name"/>
</mx:GridItem>
</mx:GridRow>
<mx:GridRow>
<mx:GridItem>
<mx:TextInput id="txtfname" />
</mx:GridItem>
<mx:GridItem>
<mx:TextInput id="txtlname"/>
</mx:GridItem>
</mx:GridRow>
<mx:GridRow>
<mx:GridItem>
</mx:GridItem>
<mx:GridItem verticalAlign="middle" horizontalAlign="right">
<mx:Button label="Button" click="queryByName()"/>
</mx:GridItem>
</mx:GridRow>
</mx:Grid>
//DATA GRID STARTS HERE
<mx:DataGrid id="customergrid"
dataProvider="{customer_srv.result.customers.customer}"
editable="true">
<mx:columns>
<mx:Array>
<mx:DataGridColumn editable="false" headerText="Customer
ID" columnName="customerid" />
<mx:DataGridColumn editable="false" headerText="Session
ID" columnName="sessid" />
<mx:DataGridColumn editable="false" headerText="Date"
columnName="orderdate" />
<mx:DataGridColumn editable="false" headerText="Time"
columnName="ordertime" />
<mx:DataGridColumn headerText="First Name"
columnName="customerfname"/>
<mx:DataGridColumn headerText="Last Name"
columnName="customerlname" />
<mx:DataGridColumn headerText="Contact F Name"
columnName="contactfname" />
<mx:DataGridColumn headerText="Contact L Name"
columnName="contactlname" />
<mx:DataGridColumn headerText="Email"
columnName="contactemail" />
<mx:DataGridColumn headerText="Phone"
columnName="contactphone" />
</mx:Array>
</mx:columns>
</mx:DataGrid>
</mx:Panel>
///PHP FUNCTION
function getCustomer(){
$firstname=$_POST['custfname'];
$lastname=$_POST['custlname'];
$fname=trim($firstname);
$lname=trim($lastname);
$conn = mysql_connect("xxx.xxx.xxx.xxx", 'xxxxxx', "xxxxxxx")
or die("Could not connect to MySQL");
mysql_select_db("xxx",$conn)or die ("could not open db".mysql_error
());
$query = "SELECT C.custID, S.sessionID, C.custFName, C.custLName,
C.contFName, C.contLName,C.contEmail, C.contPhone, C.custDepartment,
C.custCollege, S.indate, S.intime
FROM session as S, customer as C
WHERE C.custFName='$fname' and C.custLName='$lname' and S.custID =
C.custID
ORDER BY C.custID";
$result = mysql_query($query, $conn) or die(mysql_error());
echo "<customers>\n";
while ($row = mysql_fetch_array($result)){
echo "<customer>\n";
echo "<customerid>".$row['custID']."</customerid>\n";
echo "<sessid>".$row['sessionID']."</sessid>\n";
echo "<customerfname>".$row['custFName']."</customerfname>\n";
echo "<customerlname>".$row['custLName']."</customerlname>\n";
echo "<contactfname>".$row['contFName']."</contactfname>\n";
echo "<contactlname>".$row['contLName']."</contactlname>\n";
echo "<contactemail>".$row['contEmail']."</contactemail>\n";
echo "<contactphone>".$row['contPhone']."</contactphone>\n";
echo "<orderdate>".$row['indate']."</orderdate>\n";
echo "<ordertime>".$row['intime']."</ordertime>\n";
echo "<department>".$row['custDepartment']."</department>\n";
echo "<college>".$row['custCollege']."</college>\n";
echo "</customer>\n";
}
echo "</customers>";
mysql_close($conn);
}
------------------------ Yahoo! Groups Sponsor --------------------~-->
<font face=arial size=-1><a
href="http://us.ard.yahoo.com/SIG=12hn61f6h/M=362329.6886308.7839368.1510227/D=groups/S=1705007207:TM/Y=YAHOO/EXP=1122673310/A=2894321/R=0/SIG=11dvsfulr/*http://youthnoise.com/page.php?page_id=1992
">Fair play? Video games influencing politics. Click and talk back!</a>.</font>
--------------------------------------------------------------------~->
--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/flexcoders/
<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/