Go Back   CodingForums.com > :: Client side development > JavaScript programming > JavaScript frameworks

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 10-26-2012, 02:53 PM   PM User | #1
branko7171
New to the CF scene

 
Join Date: Oct 2012
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
branko7171 is an unknown quantity at this point
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.
branko7171 is offline   Reply With Quote
Old 10-27-2012, 02:26 PM   PM User | #2
sunfighter
Senior Coder

 
Join Date: Jan 2011
Location: Missouri
Posts: 2,383
Thanks: 18
Thanked 350 Times in 349 Posts
sunfighter is on a distinguished road
May not be a solution, but:

Original query has one too many Ps
Code:
FROM problem P P,
sunfighter is offline   Reply With Quote
Old 10-28-2012, 11:28 AM   PM User | #3
branko7171
New to the CF scene

 
Join Date: Oct 2012
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
branko7171 is an unknown quantity at this point
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.
branko7171 is offline   Reply With Quote
Old 10-28-2012, 04:20 PM   PM User | #4
branko7171
New to the CF scene

 
Join Date: Oct 2012
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
branko7171 is an unknown quantity at this point
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...
branko7171 is offline   Reply With Quote
Reply

Bookmarks

Tags
mysql, php

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 06:53 AM.


Advertisement
Log in to turn off these ads.