problem with where in datatables
problem with where in datatables
mkourkch
Posts: 18Questions: 0Answers: 0
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.
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.
This discussion has been closed.
Replies
is the error with your $_SESSION['userID'] variable? Do you get database syntax errors? do you get a valid SQL statement but wrong data?
the type of error is error parsing format of JSON
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
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.
[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]
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?
$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
{"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