Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Oct 2012
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Listbox doesn't populate from mysql with php

    Hello, first I'd like to mention that I'm using jQWidgets.
    The problem is as follows:
    I’m trying to populate a listbox with data from a mysql database. The data is returned from a php file called “problemiOblastData.php” as JSON. The problem is that no data is shown in the listbox.
    Now, I’ve discovered that when I change my query string in php file the listbox shows some data.
    Original query (not working) is this:

    Code:
    $query = "SELECT P.ImeDatoteke,P.ProblemId
    
    FROM problem P P,problempripadaoblasti PPO, oblast O
    
    WHERE P.ProblemId = PPO.ProblemId AND PPO.OblastId=O.OblastId
    And then I change to this:
    Code:
    $query = "SELECT P.ImeDatoteke,P.ProblemId
    
    FROM problem P";
    Source for the listbox:
    Code:
    var source4 =
    
     {
    
     async: false,
    
     datatype: "json",
    
     datafields: [
    
     { name: 'id'},
    
     { name: 'text' }
    
    
    
     ],
    
     id: 'id',
    
     url: 'problemiOblastData.php',
    
     processdata: function (data) {
    
     data.selectedOblast = $('#problemiTree').jqxTree('getSelectedItem');
    
     if (data.selectedOblast && data.selectedOblast.parentId != 0) data.selectedOblast = data.selectedOblast.id;
    
     else data.selectedOblast = "0"; // ako nista nije selektovano, ili je selektovan predmet
    
     // alert(data.selected);
    
     }
    
    
    
     };
    Adapter for the listbox:
    Code:
    var dataAdapter4 = new $.jqx.dataAdapter(source4);
    
     $("#jqxlistbox2").jqxListBox(
    
     {
    
     source: dataAdapter4,
    
     theme: 'classic',
    
     width: 200,
    
     height: 250,
    
     displayMember: 'text',
    
     valueMember: 'id'
    
     });
    I’m binding the data with:
    Code:
    $('#problemiTree').bind('select', function (event) {
    
     //var item3 = $('#problemiTree').jqxTree('getSelectedItem');
    
     //if (item3 && item3.parentId!=0)
    
     dataAdapter4.dataBind();
    
     //alert(item3.parentId);
    
     });
    Please help, thanks.

  • #2
    Senior Coder
    Join Date
    Jan 2011
    Location
    Missouri
    Posts
    3,762
    Thanks
    23
    Thanked 548 Times in 547 Posts
    May not be a solution, but:

    Original query has one too many Ps
    Code:
    FROM problem P P,

  • #3
    New to the CF scene
    Join Date
    Oct 2012
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Yeah, sorry about that. I go between 2 queries so sometimes I overlook a 'P'. It doesn't help when I delete it. Thanks, though.

  • #4
    New to the CF scene
    Join Date
    Oct 2012
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts
    SOLVED!
    I've figured out what was the problem. I passed item.label (or item), where I should have passed item.id. mySQL query in the php file requires that id, and it won't work with label etc...


  •  

    Tags for this Thread

    Posting Permissions

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