problem with where in datatables

problem with where in datatables

mkourkchmkourkch Posts: 18Questions: 0Answers: 0
edited August 2011 in DataTables 1.8
i 'm using datatables 1.8.1 but i have some problem with $sWhere . I try to add some condition in order to do filtring .
i have 3 tables in jointure my query is :

$sQuery = "
SELECT SQL_CALC_FOUND_ROWS u.idTask, u.context, u.userID, u.startDate, u.endDate, u.disabled, m.acp_label, n.username
FROM tasks u LEFT JOIN tasks_acp m ON u.idTask = m.taskID
LEFT JOIN task_employes n ON u.idTask = n.taskID


$sWhere
$sOrder
$sLimit
";
i want to add this condition : u.userID = $_SESSION['userID'] to my query.
i try to do it in varaible $sWhere but does not work.

thinks.

Replies

  • fbasfbas Posts: 1,094Questions: 4Answers: 0
    what error / state do you get?

    is the error with your $_SESSION['userID'] variable? Do you get database syntax errors? do you get a valid SQL statement but wrong data?
  • mkourkchmkourkch Posts: 18Questions: 0Answers: 0
    Dear,
    the type of error is error parsing format of JSON
  • fbasfbas Posts: 1,094Questions: 4Answers: 0
    have you checked the JSON in the debugger? that could be caused by errors and until you see what's happening in your script you're just guessing.
  • mkourkchmkourkch Posts: 18Questions: 0Answers: 0
    how can i check this please?
  • fbasfbas Posts: 1,094Questions: 4Answers: 0
    which browser are you using?

    chrome has debugger built in. type shift-ctrl-j, or right click on page and selected "inspect element". the network tab shows timings and response strings for all your network requested objects (you might need to re-load the page after you open the debugger to get things shown)

    firefox has a very good plug-in to download called FireBug that shows the same kind of info and interface. download http://getfirebug.com/

    IE? I think you're out of luck with IE - use one of the above.

    other browsers? not sure, but I bet safari uses something very similar to Chrome (they're both built on the same library, though maybe their javascript engines are different). opera - probably supports firebug.

    example view of FireFox's Firebug debugger, looking at AJAX response: http://i.imgur.com/VnNXs.png

    browser debugger is a huge and helpful part of javascript programming. everyone should know how to use one of the debuggers. I don't know of any good tutorials, but try googling: http://www.google.com/search?sourceid=chrome&ie=UTF-8&q=javascript+debugger+tutorial
  • fbasfbas Posts: 1,094Questions: 4Answers: 0
    I guess I was wrong about IE: http://berniesumption.com/software/how-to-debug-javascript-in-internet-explorer/
  • mkourkchmkourkch Posts: 18Questions: 0Answers: 0
    i'm not able to fint this error. but i repeat if you can help me :

    i want that my query contain a condition about one field. when i write :

    $sQuery = "
    SELECT SQL_CALC_FOUND_ROWS u.idTask, u.context, u.userID, u.startDate, u.endDate, u.disabled, m.acp_label, n.username
    FROM tasks u LEFT JOIN tasks_acp m ON u.idTask = m.taskID
    LEFT JOIN task_employes n ON u.idTask = n.taskID
    WHERE u.userID = $_SESSION['userID']

    $sOrder
    $sLimit
    ";
    if you have another issue to resolve this please.
    thinks.
  • fbasfbas Posts: 1,094Questions: 4Answers: 0
    try:
    [code]
    $sQuery = "
    SELECT SQL_CALC_FOUND_ROWS u.idTask, u.context, u.userID, u.startDate, u.endDate, u.disabled, m.acp_label, n.username
    FROM tasks u LEFT JOIN tasks_acp m ON u.idTask = m.taskID
    LEFT JOIN task_employes n ON u.idTask = n.taskID
    WHERE u.userID = ".$_SESSION['userID']."

    $sOrder
    $sLimit
    ";
    [/code]
  • mkourkchmkourkch Posts: 18Questions: 0Answers: 0
    doesn't work .
    only the same message error :
    DataTables warning: JSON data from server could not be parsed. This is caused by a JSON formatting error
    if some one can help me please?
  • mkourkchmkourkch Posts: 18Questions: 0Answers: 0
    when i do that :

    $sQuery = "
    SELECT SQL_CALC_FOUND_ROWS u.idTask, u.context, u.userID, u.startDate, u.endDate, u.disabled, m.acp_label, n.username
    FROM tasks u LEFT JOIN tasks_acp m ON u.idTask = m.taskID
    LEFT JOIN task_employes n ON u.idTask = n.taskID
    WHERE u.userID = 50
    $sOrder
    $sLimit
    ";
    it works but just the variable in a query is a problem
  • fbasfbas Posts: 1,094Questions: 4Answers: 0
    I can't help you until you tell me what the debugger shows.
  • mkourkchmkourkch Posts: 18Questions: 0Answers: 0
    this is the result of the php file processing:

    {"sEcho":0,"iTotalRecords":"4","iTotalDisplayRecords":"15","aaData":[["63","meeting","2011-08-07","2011-08-07","1","acp4","empl4"],["64","voyage","2011-08-08","2011-08-08","0","ACP1","empl1"],["64","voyage","2011-08-08","2011-08-08","0","ACP1","empl2"],["64","voyage","2011-08-08","2011-08-08","0","ACP1","empl3"],["64","voyage","2011-08-08","2011-08-08","0","ACP1","empl4"],["64","voyage","2011-08-08","2011-08-08","0","ACP1","empl5"],["64","voyage","2011-08-08","2011-08-08","0","ACP2","empl1"],["64","voyage","2011-08-08","2011-08-08","0","ACP2","empl2"],["64","voyage","2011-08-08","2011-08-08","0","ACP2","empl3"],["64","voyage","2011-08-08","2011-08-08","0","ACP2","empl4"],["64","voyage","2011-08-08","2011-08-08","0","ACP2","empl5"],["65","casserole","2011-08-24","2011-08-25","0","ACP1","empl4"],["65","casserole","2011-08-24","2011-08-25","0","ACP2","empl4"],["66","casserole","2011-08-24","2011-08-25","0","ACP1","empl4"],["66","casserole","2011-08-24","2011-08-25","0","ACP2","empl4"]]}

    i hope that this result that you wait to look.
    thinks
  • fbasfbas Posts: 1,094Questions: 4Answers: 0
    is that from the debugger, or did you point your browser at the your server script?
This discussion has been closed.