4 Replies Latest reply on Jun 23, 2010 6:07 AM by djh88ukwb

    Pull data from database using php script, and input to datagrid.

    djh88ukwb Level 1

      Hello all,

       

      I intend to use the following php script to pull data from a database.

       

      I then want to display that data into a datagrid, the datagrid has the columns job ref, company and position.

       

      The php script i have is

       

      <?php
      $hostname_conn = "localhost";
          $username_conn = "";
          $password_conn = "";

          $conn = mysql_connect($hostname_conn, $username_conn, $password_conn);

          mysql_select_db("videochat");

          $query = "SELECT * FROM jobs";

          $result = mysql_query($query);

          $row=mysql_fetch_array($result);

          $ref = $row['jobref'];
          $company = $row['company'];
          $position = $row['position'];

          echo "<ref>$ref</ref>";
          echo "<company>$company</company>";
          echo "<position>$position</position>";

      ?>

       

      Could anyone show me how i chuck this data into a grid ?

       

      Thanks

        • 1. Re: Pull data from database using php script, and input to datagrid.
          David_F57 Level 5

          hi,

           

           

          You should start using amf, either zendamf which is used by the data wizards in flashbuilder 4 or with amfphp which is probably better than zend but doesn't have all the nicities like creating value objects.

           

          http://flashhub.net/filter/

           

           

           

          this project uses amfphp, basically it uses remoteobjects so the php returned is in an arraycollection ready to put straight into a grid or datagroup.

           

          if you need help with this sort of thing pm me and I can do a connect session..

           

          the php services file for the calls used in the application

           

          <?php

          class pets

          {

          var $db_host = 'localhost';

          var $db_name = 'flashhub_pets';

          var $db_user = 'flashhub_david';

          var $db_pwd = 'david';

           

          function pets()

           

          {

          // Define the methodTable for this class in the constructor

           

          $this->methodTable = array(

          "getPets" => array(

          "description" => "Pets Database",

          "access" => "remote"

          )

          );

          }

           

          function getAllPets()

          {

          $mysql = mysql_connect($this->db_host, $this->db_user, $this->db_pwd);

          mysql_select_db( $this->db_name);

          $Query = "SELECT * from pet";

          $Result = mysql_query( $Query );

          return( $Result );

          }

           

          function getTypeOfPets($category)

          {

          $mysql = mysql_connect($this->db_host, $this->db_user, $this->db_pwd);

          mysql_select_db( $this->db_name);

          $Query = "SELECT * from pet where CATEGORY=$category";

          $Result = mysql_query( $Query );

          return( $Result );

           

          }

           

          function getCategories()

          {

          $mysql = mysql_connect($this->db_host, $this->db_user, $this->db_pwd);

          mysql_select_db( $this->db_name);

          $Query = "SELECT * from category";

          $Result = mysql_query( $Query );

          return( $Result );

          }

          }

          ?>

           

          David

          • 2. Re: Pull data from database using php script, and input to datagrid.
            djh88ukwb Level 1

            While looking about on google i noticed alot of people where saying to use amf, is it easy to install ? I am trying to build out a project that is going to require alot of mysql connectivity so I suppose i should really install amf.

            • 3. Re: Pull data from database using php script, and input to datagrid.
              David_F57 Level 5

              hi,

               

              If you look at the code in the above web reference I gave you and the php thats all you need programmatically. amfphp is about 1.2mb of php classes that you have on your server it also includes a class browser that lets you test the php classes.

               

              If you have 5 minutes I can show you how to set it up.

               

              https://na2.connectnow.acrobat.com/davidfabris

               

               

              David.

              • 4. Re: Pull data from database using php script, and input to datagrid.
                djh88ukwb Level 1

                WOuld you be able to help with the amfphp install process?  I use a linux server that i haveSSH control over using putty.