Need to add a where clause by default before page load

Need to add a where clause by default before page load

aswebtechnologyaswebtechnology Posts: 19Questions: 0Answers: 0
edited June 2012 in General
Hi,

I am need to execute a query
$sql ="select name, address, city from users where user_type=1"

I have already added the fields name, address and city in array in server processing file but I need to have the clause where user_type=1 into it so that only records related to user_type = 1 should show up and further search / filtering is made on them.

Please help me to achieve it. Its really urgent for me. Thanks in advance.

Replies

  • snarf2larfsnarf2larf Posts: 64Questions: 0Answers: 0
    If you are using the PHP script you can alter the $sWhere variable before it is used in $sQuery and add any additional filters you need.
  • aswebtechnologyaswebtechnology Posts: 19Questions: 0Answers: 0
    I tried that but its not working. Here is my code

    [code]
    $sWhere = "WHERE user_type=1";
    if ( isset($_GET['sSearch']) && $_GET['sSearch'] != "" )
    {
    $sWhere = " AND";
    for ( $i=0 ; $i
  • aswebtechnologyaswebtechnology Posts: 19Questions: 0Answers: 0
    Using this code the datatable is showing results while on page load but filtering is not working. Its stuck at Processing.....

    Is there any way I can echo the ajax response or echo sql query used at ajax response in filtering the rows.

    Any help will be highly appreciated.
  • snarf2larfsnarf2larf Posts: 64Questions: 0Answers: 0
    Yes, you can echo the $sQuery variable which will show you the entire built query and find the problem. To view the server response use a tool like Firebug in Firefox or Chrome. From there you can try to run the query built directly in SQL and find the problem.
This discussion has been closed.