jQuery UI Widgets Forums Lists DropDownList generic php search engine

This topic contains 2 replies, has 1 voice, and was last updated by  claudegel 10 years, 4 months ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
  • generic php search engine #64722

    claudegel
    Participant

    is it possible to pass the table name and other parameter like where clause, order by close in the request to the php file that will do the data search in a myswl database

    I need to create a generic php search engine file that can retreive data from any mysql table giving that I provide the needed information when I’m calling the php file

    something like


    $(document).ready(function () {
    var source =
    {
    datatype: “json”,
    cache: false,
    select: true, <– allow to do a select query on the database, could be replace by a update: true so we call the same php file and it switch to the correct action
    base: “client”, <– database table name
    datafields: [
    {name: ‘nocli’},
    {name: ‘nom’}
    ],
    nbfield: 2,
    numrow: “*”, <– max number of row retreived from the table, *=all
    filtre: “”, <– where clause
    ordre: “”, <–order by…
    url: ‘engine.php’,
    };
    var dataAdapter = new $.jqx.dataAdapter(source);
    $(“#dropdownlist”).jqxDropDownList(
    {
    source: dataAdapter,
    theme: ‘classic’,
    width: 200,
    height: 25,
    selectedIndex: 0,
    displayMember: ‘nom’,
    valueMember: ‘nocli’
    });
    });
    nothing is sent to the engine.php. Should I specify the GET or POST method ??

    generic php search engine #64741

    claudegel
    Participant

    OK now it work I can send request to the engine and get data back with the possibility to filter data on demand. My problem now is the data I<m getting back from the search engine do not show up in the dropdown list. It look like the number of item in the dropdown list is correct but I only get blanck item in the list

    the data I get back is in this state:
    [[“nom=>Yvan Perreault et Fils qc Inc.,nocli=>227-1”],[“nom=>Yvan Perreault et Fils Inc.,nocli=>227”],[“nom=>…..
    …..,[“nom=>john doe,nocli=>612”]]

    my code is like this in the index.php:

    var url = “../engine/index.php”;
    // prepare the data
    var source =
    {
    datatype: “json”,
    type: “POST”,
    datafields: [
    { name: ‘nocli’ },
    { name: ‘nom’ }
    ],
    url: url,
    async: false,
    data: {
    select: true,
    dbase: “client”,
    nbfield: 2,
    numrow: “*”,
    filtre: “-“,
    ordre: “nom desc”,
    field: [‘nom’, ‘nocli’]
    }
    };
    var dataAdapter = new $.jqx.dataAdapter(source);
    // Create a jqxDropDownList
    $(“#jqxWidget”).jqxDropDownList({
    selectedIndex: 0, source: dataAdapter, displayMember: “nom”, valueMember: “nocli”, width: 200, height: 25
    });
    $(“#jqxWidget”).jqxDropDownList({placeHolder: “Choisir:”});
    // subscribe to the select event.
    $(“#jqxWidget”).on(‘select’, function (event) {
    if (event.args) {
    var item = event.args.item;
    if (item) {
    var valueelement = $(“<div></div>”);
    valueelement.text(“Value: ” + item.value);
    var labelelement = $(“<div></div>”);
    labelelement.text(“Label: ” + item.label);
    $(“#selectionlog”).children().remove();
    $(“#selectionlog”).append(labelelement);
    $(“#selectionlog”).append(valueelement);
    }
    }
    });

    something should be missing to have the data showing up in my dropdown list

    generic php search engine #64744

    claudegel
    Participant

    Ok sorry but I’ve finally found that the bug was in my php script sending a bad json encoded data
    but I still don’t know how to solve it. So I<ve moved my question to the dataAdapter section.
    The scrip is working if I’m sending back a know number of mysql table field data. But I need to have a php script that can handle a variable number of mysql table field data to send back via json_encoded.
    fixed number of data field work great but trying to handle a variable number of field data do not work and send corrupted json data.
    see my post in data Adapter section

    Thanks

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.