1. #1
    Sencha User
    Join Date
    Jan 2009
    Posts
    2
    Vote Rating
    0
    mahmutdur is on a distinguished road

      0  

    Default Extjs 4 + PHP + MYSQL

    Extjs 4 + PHP + MYSQL


    Hello everbody,

    i like extjs but i have so many problems.

    i need mysql and extjs charts and mysql scripts please somebody help me i need mysql charts with extjs

    who help me ?

    i cant find this style script !!!

  2. #2
    Touch Premium Member
    Join Date
    Jul 2011
    Location
    Cuernavaca, Mexico
    Posts
    53
    Vote Rating
    1
    ErnestoR is on a distinguished road

      0  

    Default


    Hello mahmutdur,

    I'll be glad to help you. What kind of problems are you encountering? You can contact me by email if you like.

    Cheers

  3. #3
    Sencha User
    Join Date
    Nov 2011
    Posts
    149
    Vote Rating
    1
    sachintaware is on a distinguished road

      0  

    Default extjs+php+mysql

    extjs+php+mysql


    Hello ErnestoR
    I am looking for a similar help.This is my php file.
    I want to display the fetched results in a grid.What would be resultant grid.js to display the records fetched using the json_encode function.

    PHP file:

    <?php
    $sql2="select * from register";
    $result2=mysql_query($sql2);

    //$output=mysql_fetch_assoc($result2);
    //$output=FetchAll($result2);
    /*echo "<pre>";
    print_r($output);
    exit;*/

    for ($i=0; $row = mysql_fetch_array($result2); $i++)
    {
    $return[$i]['username'] = $row['username'];
    $return[$i]['firstname'] = $row['firstname'];
    $return[$i]['lastname'] = $row['lastname'];
    $return[$i]['email'] = $row['email'];
    $return[$i]['state'] = $row['state'];
    $return[$i]['city'] = $row['city'];
    $return[$i]['country'] = $row['country'];
    }

    echo json_encode($return);

    ?>

    I have tried this,but does not work

    <script type="text/javascript">

    Ext.onReady(function() {
    Ext.define('Company', {
    extend: 'Ext.data.Model',
    fields: ['username', 'firstname', 'lastname', 'email']
    });

    var store_company = new Ext.data.Store({
    model: 'Company',
    proxy: {
    type: 'ajax',
    url: 'connection.php',
    reader: {
    type: 'json',
    //root: 'companies'
    }
    }
    });

    var grid_company = Ext.create('Ext.grid.Panel', {
    store: store_company,
    columns:[
    {
    text : 'User Name',
    width : 200,
    dataIndex: 'username'
    },
    {
    text : 'Firstname',
    width : 200,
    dataIndex: 'firstname'
    },
    {
    text : 'Lastname',
    width : 200,
    dataIndex: 'lastname'
    },
    {
    text : 'Email',
    width : 250,
    dataIndex: 'email'
    }
    ],
    height: 200,
    width: 850,
    title: 'Company List',
    renderTo: 'grid-company',

    });
    store_company.load();
    });
    </script>

    Any help would be appreciated.

    Regards
    Sachin

  4. #4
    Sencha User
    Join Date
    Nov 2011
    Posts
    149
    Vote Rating
    1
    sachintaware is on a distinguished road

      0  

    Default


    @Ernesto

    Hello
    Just to add to the above post.I am getting my values in the JSON format from the php file.
    The output is this
    [{"username":"Sachin","firstname":"Sachin","lastname":"Taware","email":"sachi@gmail.com","state":"MH","city":"Pune","country":"India"},{"username":"Rahul","firstname":"Rahul","lastname":"Dravid","email":"rdravid@gmail.com","state":"KA","city":"Bangalore","country":"India"},{"username":"MS","firstname":"MS","lastname":"Dhoni","email":"ms@gmail.com","state":"JH","city":"Ranchi","country":"India"},{"username":"viru","firstname":"Virender","lastname":"Sehwag","email":"viru123@gmail.com","state":"DL","city":"Delhi","country":"India"},{"username":"Gauti","firstname":"Gautam","lastname":"Gambhir","email":"gauti@gmail.com","state":"DL","city":"Delhi","country":"India"},{"username":"jumbo","firstname":"Anil","lastname":"kumble","email":"anil@gmail.com","state":"KA","city":"Bangalore","country":"India"}]


    But I am not able to display them in the grid.

    Regards
    Sachin

  5. #5
    Touch Premium Member
    Join Date
    Jul 2011
    Location
    Cuernavaca, Mexico
    Posts
    53
    Vote Rating
    1
    ErnestoR is on a distinguished road

      0  

    Default


    @sachintaware

    As a hint please use CODE tags so we can view your code better.

    The problem is in your store configuration and your php output.

    Your Store should be configured as

    Code:
    var store_company = new Ext.data.Store({
              model: 'Company',
              proxy: {
                  type: 'ajax',
                  url: 'connection.php',
                  reader: {
                      type: 'json',
                      root: 'companies'// The READER should have a root
                  }
              }
           });
    And in your php code it has to return something like this

    Code:
    {
        "success": true,    "companies": [          {"username":"Sachin","firstname":"Sachin","lastname":"Taware","email":"sachi@gmail.com","state":"MH","city":"Pune","country":"India"},       {"username":"Rahul","firstname":"Rahul","lastname":"Dravid","email":"rdravid@gmail.com","state":"KA","city":"Bangalore","country":"India"},
    
    {"username":"MS","firstname":"MS","lastname":"Dhoni","email":"ms@gmail.com","state":"JH","city":"Ranchi","country":"India"}, {"username":"viru","firstname":"Virender","lastname":"Sehwag","email":"viru123@gmail.com","state":"DL","city":"Delhi","country":"India"}, {"username":"Gauti","firstname":"Gautam","lastname":"Gambhir","email":"gauti@gmail.com","state":"DL","city":"Delhi","country":"India"}, {"username":"jumbo","firstname":"Anil","lastname":"kumble","email":"anil@gmail.com","state":"KA","city":"Bangalore","country":"India"}
    ] }
    Where companies is the ROOT of your data. By default the successProperty of the store is "success".

    Hope this helps.

  6. #6
    Sencha User
    Join Date
    Nov 2011
    Posts
    149
    Vote Rating
    1
    sachintaware is on a distinguished road

      0  

    Default Extjs 4 + JAVA+ MYSQL

    Extjs 4 + JAVA+ MYSQL


    @Ernesto
    Thank you for the prompt reply and sorry for the inconvenience as it was my first post.
    I got it working without the root attribute.But I would like you to throw some light on it.

    How can the json_encode function return values with the root name attached to it?

    Also,I want to perform the similar operation using JAVA as the backend.I have written a connection class which works fine.But,i am not sure if there is any similar function like json_encode() in java as in PHP.

    So,if you can add a code snippet of how I can use servlet to submit the request to json and display in a grid,it will be very helpful.

    Regards
    Sachin

  7. #7
    Touch Premium Member
    Join Date
    Jul 2011
    Location
    Cuernavaca, Mexico
    Posts
    53
    Vote Rating
    1
    ErnestoR is on a distinguished road

      0  

    Default


    I use something like this for the response:

    Response Class
    PHP Code:
    <?php
    /**
     * @class Response
     * A simple JSON Response class.
     */
    class Response {
        public 
    $success$data$message$errors$tid$trace;

        public function 
    __construct($params = array()) {
            
    $this->success  = isset($params["success"]) ? $params["success"] : false;
            
    $this->message  = isset($params["message"]) ? $params["message"] : '';
            
    $this->data     = isset($params["data"])    ? $params["data"]    : array();
        }

        public function 
    to_json() {
            return 
    json_encode(array(
    //here is where we create extra values in json
                
    'success'   => $this->success,
    //  'totalRecords'=>$this->totalRecords, //in Order to use  totalRecords we have to declare it for the class
                
    'message'   => $this->message,
                
    'data'      => $this->data
            
    ));
        }
    }
    And the implementation

    PHP Code:
    <?php

    //Import Response Class
    require_once 'lib/response.php';

    //Creating User Class
    class User
    {        
            var 
    $userID;
            var 
    $name;
            var 
    $lastname;
                    var 
    $age;
    }
    //Make DB connection
    require_once('database_connection.php');
    //Query BD
    $result mysql_query("SELECT * FROM Users");
    $query_array=array();
    $i=0;
    //Iterate all Select
    while($row mysql_fetch_array($result))
      {
        
    //Create New User instance
        
    $user = new User();
        
    //Fetch User Info
        
    $user->userID=$row['userID'];
        
    $user->name=$row['name'];
        
    $user->lastname=$row['lastname'];
        
    $user->age=$row['age'];
        
        
    //Add User to ARRAY
        
    $query_array[$i]=$user;
        
    $i++;
      }
    mysql_close($con);

    //Creating Json Array needed for Extjs Proxy
    $res = new Response();
    $res->success true;
    $res->message "Loaded data";
    $res->data $query_array;
    //Printing json ARRAY
    print_r($res->to_json());
    ?>
    If you like i can send you a basic example of a CRUD using Extjs4 + PHP +MySQL. Just send me your email in a private message.
    And about Java haven't really tried to integrating it with it right now I'm trying to integrate it with Groovy/Grails.

  8. #8
    Touch Premium Member
    Join Date
    Jul 2011
    Location
    Cuernavaca, Mexico
    Posts
    53
    Vote Rating
    1
    ErnestoR is on a distinguished road

      1  

    Default


    Extjs 4 MVC, PHP and MySQL

    Due to constant private messages for an example of Extjs4 Php and Mysql I've started a Github account you can download the source code here

    https://github.com/ErnestoR/Extjs4_PHP_MySQL

  9. #9
    Sencha User
    Join Date
    Nov 2011
    Posts
    149
    Vote Rating
    1
    sachintaware is on a distinguished road

      0  

    Default


    Thats really cool!!good job Ernesto.That would surely help many.

    Cheers!

    Sachin
    www.optionsconsultancy.com

  10. #10
    Touch Premium Member
    Join Date
    Dec 2010
    Posts
    140
    Vote Rating
    2
    tomdchi is on a distinguished road

      0  

    Default


    Awesome job. I am moving over from extjs 3 and this simple example using the proper architecture helped tons.

film izle

hd film izle

film sitesi

takipci kazanma sitesi

takipci kazanma sitesi

güzel olan herşey

takipci alma sitesi

komik eğlenceli videolar