Welcome to the nuBuilder Forums!
Register and log in to access exclusive forums and content available only to registered users.
Register and log in to access exclusive forums and content available only to registered users.
Browse Table Filter Options Topic is solved
-
- Posts: 55
- Joined: Tue Apr 16, 2019 1:32 pm
Re: Browse Table Filter Options
Let me correct this...actually it does appear that it is updating the records based off of the "Word" dropdown, only it's not limiting the records to those=2 when "2" is selected in the dropdown. Further, when "32" is selected in the dropdown--nothing is displayed even though there are records with 32 in the Word column
-
- Posts: 55
- Joined: Tue Apr 16, 2019 1:32 pm
Re: Browse Table Filter Options
kev1n wrote:This is what it should look like:
Note that there is no final semicolon (;)Code: Select all
SELECT * FROM Channels WHERE ((Word = '#nuBrowseTitle0_dropdown#' AND LOCATE('#', '#nuBrowseTitle0_dropdown#') <> 1 ) OR '#nuBrowseTitle0_dropdown#' = '' OR LOCATE('#', '#nuBrowseTitle0_dropdown#') = 1) AND ((Type = '#nuBrowseTitle1_dropdown#' AND LOCATE('#', '#nuBrowseTitle1_dropdown#') <> 1 ) OR '#nuBrowseTitle1_dropdown#' = '' OR LOCATE('#', '#nuBrowseTitle1_dropdown#') = 1)
Solved it. The problem was in the references to nuBrowseTitle0 etc...They needed to reference the index of the column not the vardata0, 1, 2 etc. Thus even though Word was the first column with a dropdown, it was index 3. This solved this issue. Now onto dynamically populating the dropdowns! Thanks
-
- nuBuilder Team
- Posts: 4302
- Joined: Sun Oct 14, 2018 6:43 pm
- Has thanked: 71 times
- Been thanked: 445 times
- Contact:
Re: Browse Table Filter Options
Can you upload a picture of your table title names (of the Browse screen)?
-
- Posts: 55
- Joined: Tue Apr 16, 2019 1:32 pm
Re: Browse Table Filter Options
Unfortunately I can't do that, however I can list them (From the SQL Table):kev1n wrote:Can you upload a picture of your table title names (of the Browse screen)?
channel_names, short_names, web_address, word, number, offset, resolution, digital, type, format, channel
The dropdowns are only on: word, number, offset & channel....
The tables have the same names displayed in nubuilder, except they are uppercase.
Thanks
-
- nuBuilder Team
- Posts: 4302
- Joined: Sun Oct 14, 2018 6:43 pm
- Has thanked: 71 times
- Been thanked: 445 times
- Contact:
Re: Browse Table Filter Options
If this is the order of your columns, then the indexes are not correct:
channel_names, short_names, web_address, word, number, offset, resolution, digital, type, format, channel
word ---> column nr. 4 = index 3
number ---> column nr. 5 = index 4
And also the sql must be changed:
SELECT * FROM Channels
WHERE
channel_names, short_names, web_address, word, number, offset, resolution, digital, type, format, channel
word ---> column nr. 4 = index 3
number ---> column nr. 5 = index 4
Code: Select all
var data3 = ["", "input", "word", "image"]; // static values to be added to the dropdown
addBrowseTitleDropDown(3, data3);
var data4 = ["", "text", "nuDate", "nuScroll"]; // static values to be added to the dropdown
addBrowseTitleDropDown(4, data4);
SELECT * FROM Channels
WHERE
Code: Select all
((word = '#nuBrowseTitle3_dropdown#' AND LOCATE('#', '#nuBrowseTitle3_dropdown#') <> 1 )
OR '#nuBrowseTitle3_dropdown#' = '' OR LOCATE('#', '#nuBrowseTitle3_dropdown#') = 1)
AND
((number = '#nuBrowseTitle4_dropdown#' AND LOCATE('#', '#nuBrowseTitle4_dropdown#') <> 1 )
OR '#nuBrowseTitle4_dropdown#' = '' OR LOCATE('#', '#nuBrowseTitle4_dropdown#') = 1
-
- Posts: 55
- Joined: Tue Apr 16, 2019 1:32 pm
Re: Browse Table Filter Options
Yep. It's working great with the static values! Column/indexes all written correctly. This appears to be the same JavaScript for the static values though. How would I go about dynamically populating that list with unique values from the column?
-
- nuBuilder Team
- Posts: 4302
- Joined: Sun Oct 14, 2018 6:43 pm
- Has thanked: 71 times
- Been thanked: 445 times
- Contact:
Re: Browse Table Filter Options
Example to populate distinct values of the word column:Alohajoe5 wrote:Yep. It's working great with the static values! Column/indexes all written correctly. This appears to be the same JavaScript for the static values though. How would I go about dynamically populating that list with unique values from the column?
You need to write a PHP script that retrieves the values from the db. Add this to PHP BB (Before Browse).
Code: Select all
function sqlWords() {
return "SELECT DISTINCT word FROM Channels";
}
function getBase64JsonDTString($sql) {
$result = nuRunQuery($sql);
$a = array();
while ($row = db_fetch_row($result)) {
$a[] = $row;
}
return base64_encode(json_encode( $a ));
}
$w = getBase64JsonDTString(sqlWords());
$js = "
function getWords() {
return atob('$w');
}
";
nuAddJavascript($js);
Code: Select all
var data3 = JSON.parse(getWords());
addBrowseTitleDropDown(3,data3);
-
- Posts: 55
- Joined: Tue Apr 16, 2019 1:32 pm
Re: Browse Table Filter Options
I'll post what my code in a little bit, but the problem I'm having right now is the code, as edited, no longer displays the drop-downs.
-
- Posts: 55
- Joined: Tue Apr 16, 2019 1:32 pm
Re: Browse Table Filter Options
Ok, I've got the PHP, Javascript, & SQL all playing nice with each other; however, I am left with two final issues:
1.) The items in the dropdown are randomly ordered (likely by first instance in the db table). I tried adding: ORDER BY ASC in the PHP under the SELECT DISTINCT word FROM Channels, but this didn't seem to work.
2.) Once a selection is made in one of the dropdown menus, there is no ability to go back to viewing all records, you can simply change to viewing another individual record. I tried adding push("") in the JavaScript and an include () in the PHP, however neither gave me a "All" option that would have cleared the selection in the dropdown.
Thanks
1.) The items in the dropdown are randomly ordered (likely by first instance in the db table). I tried adding: ORDER BY ASC in the PHP under the SELECT DISTINCT word FROM Channels, but this didn't seem to work.
2.) Once a selection is made in one of the dropdown menus, there is no ability to go back to viewing all records, you can simply change to viewing another individual record. I tried adding push("") in the JavaScript and an include () in the PHP, however neither gave me a "All" option that would have cleared the selection in the dropdown.
Thanks
-
- Posts: 55
- Joined: Tue Apr 16, 2019 1:32 pm
Re: Browse Table Filter Options
I've solved these issues, I will post the code in a bit for anyone else who might be interested in this topic.