Results 1 to 3 of 3

Thread: How to get the result from multiple variables with multiple values.

  1. #1
    Sencha User
    Join Date
    Mar 2012
    Posts
    1
    Vote Rating
    0
      0  

    Default How to get the result from multiple variables with multiple values.

    Hi, I have a table student_subject which stores the subject of the student from the student_info table. My problem is since the student have multiple subjects, how I can get those other subjects? Should I use the $fetchRecords['x'] instead of $arg like this :

    echo '{"rootRecords":'.@json_encode($fetchRecords['x'].........).'}';

    below is my function

    function getRecords(){
    $readRecords= mysql_query("select student_info.student_id, student_name, student_lastname,subject_name FROM student_info, student_subject WHERE student_info.id = student_subject.student_id GROUP by student_info.student_id");

    while ($fetchRecords = mysql_fetch_assoc($readRecords)){

    $arg[] = array( 'sid' => $fetchRecords['student_id'] , 'lname' => $fetchRecords['student_lastname'] ,'fname' => $fetchRecords['student_name'], 'subjects' => $fetchRecords['subject_name']);
    }
    echo '{"rootRecords":'.@json_encode($arg).'}';
    }




    Ext.define('Data', {

    extend: 'Ext.data.Model',
    fields: [

    {name: 'what will I use in this fields?'},

    ]
    });



    Thank you very much in advance and more power.

  2. #2
    Sencha - Sr Software Engineer mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    39,556
    Vote Rating
    1272
      0  

    Default

    You have sid, lname, fname and subjects fields.
    Mitchell Simoens @LikelyMitch
    Sencha Inc, Senior Software Engineer
    ________________
    Learn BBCode and use it! Checkout the CODE tag!

    Check out my GitHub, lots of nice things for Ext JS and Sencha Touch
    https://github.com/mitchellsimoens

  3. #3
    Sencha User
    Join Date
    Apr 2012
    Posts
    2
    Vote Rating
    0
      0  

    Default

    Quote Originally Posted by cladawan View Post
    Hi, I have a table student_subject which stores the subject of the student from the student_info table. My problem is since the student have multiple subjects, how I can get those other subjects? Should I use the $fetchRecords['x'] instead of $arg like this :

    echo '{"rootRecords":'.@json_encode($fetchRecords['x'].........).'}';

    below is my function

    function getRecords(){
    $readRecords= mysql_query("select student_info.student_id, student_name, student_lastname,subject_name FROM student_info, student_subject WHERE student_info.id = student_subject.student_id GROUP by student_info.student_id");

    while ($fetchRecords = mysql_fetch_assoc($readRecords)){

    $arg[] = array( 'sid' => $fetchRecords['student_id'] , 'lname' => $fetchRecords['student_lastname'] ,'fname' => $fetchRecords['student_name'], 'subjects' => $fetchRecords['subject_name']);
    }
    echo '{"rootRecords":'.@json_encode($arg).'}';
    }




    Ext.define('Data', {

    extend: 'Ext.data.Model',
    fields: [

    {name: 'what will I use in this fields?'},

    ]
    });



    Thank you very much in advance and more power.
    Thanks you for the post.
    __________________
    Watch Wrath of the Titans Online Free

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •