0 Replies Latest reply on Oct 11, 2007 5:27 AM by JonoB

    New to this...

    JonoB Level 1
      Hi all.

      Im a complete newbie when it comes to Flex, and I am just trying it out for the first time.

      I have the following flex and php files, which seem to work fine, with one exception: I cannot see any data in the columns of the datagrid. The data is added when I submit (I check the mysql database,and it is inserted), and the datagrid scrollbar moves to indicate this, but I cant actually see the data at all. When I select any of the rows in the datagrid, the correct email value is shown in the textbox. What am I missing out on?

      Something to do with the DataGridColumn, but I cant figure out what.

      Thanks for any help that you can provide




      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml"
      layout="absolute"
      creationComplete="userRequest.send()">

      <mx:HTTPService id="userRequest" url=" http://localhost/flex/php/request.php" useProxy="false"
      method="POST">
      <mx:request xmlns="">
      <username>{username.text}</username>
      <emailaddress>{emailaddress.text}</emailaddress>
      </mx:request>
      </mx:HTTPService>

      <mx:Form x="22" y="10" width="493">
      <mx:HBox>
      <mx:Label text="Username"/>
      <mx:TextInput id="username"/>
      </mx:HBox>

      <mx:HBox>
      <mx:Label text="Email Address"/>
      <mx:TextInput id="emailaddress"/>
      </mx:HBox>

      <mx:Button label="Submit" click="userRequest.send()"/>
      </mx:Form>

      <mx:DataGrid id="gridUserRequest" x="22" y="128"
      dataProvider="{userRequest.lastResult.users.user}">

      <mx:columns>
      <mx:DataGridColumn headerText="User ID" dataField="userid"/>
      <mx:DataGridColumn headerText="User Name" dataField="username"/>
      </mx:columns>
      </mx:DataGrid>

      <mx:TextInput x="22" y="292" id="selectedemailaddress"
      text="{UserRequest.selectedItem.emailaddress}"/>

      </mx:Application>




      <?php

      //connect to the database

      $dbname="sample";
      $mysql_access = mysql_connect("localhost", "root", "");
      mysql_select_db($dbname, $mysql_access);

      if( $_POST["emailaddress"] AND $_POST["username"])
      {
      //add the user
      $Query = "INSERT INTO users VALUES ('', '".$_POST['username'].
      "', '".$_POST['emailaddress']."')";
      $Result = mysql_query( $Query );
      }
      //return a list of all the users
      $Query = "SELECT * from users";
      $Result = mysql_query( $Query );
      $Return = "<users>";
      while ( $User = mysql_fetch_object( $Result ) )
      {
      $Return .= "<user><userid>".$User->userid."</userid><username>".
      $User->username."</username><emailaddress>".$User->emailaddress.
      "</emailaddress></user>";
      }
      $Return .= "</users>";
      mysql_free_result( $Result );
      print ($Return)
      ?>