How To Set Condition?

Hai,
I have a problem in my website(lawyer Document Management) when i give permission to users…

 1. Primary User - admin
 2. Secondary User - Employees (xxxx)
  1. No individual Pages for admin and Employees.

When Admin Login:

    Admin have set permission(Add,Edit,Delete,View) to users, also admin submit all the client details.
    The user Permission not for admin..so all the details must be displayed. 

When Employees Login:

  Here One Popup window display,In that window select one case id..then that selected case id is displayed in that every pages.
  In the userpermission table(fieldname-user_view_status) is used to hide or display the details in user area.

if user_view_status=‘1’ means display
if user_view_status=‘0’ means don’t display

Error:
The Problem is when admin login,then it display the selected case id only… i want all the case id must displayed in admin area…

Add New Case Query:By Admin

<?php

session_start();
ob_start();

include ‘config/connect.php’;
include ‘config/paging.php’;
//include ‘config/functions.php’;

class User

{

//insert and update

//add newcase

function newcase()

{
    $post=$_POST;

    if(!isset($_POST['id']))
    {
    
    //case_id generation
      $sel=mysql_query("select * from dms_case order by id desc");
      $fet=mysql_fetch_assoc($sel);
      $id=$fet['id']+1;
      //$case_id=$fet['case_id'];
      //$case_id="CA".$id;
      $doc="DOC".$id;
      $statid="STA".$id;
      

      $case_id=$_REQUEST['case_id'];
      
      $structure = "casedocuments/".$case_id;
      mkdir($structure, 0755, true);
    
      $structures = "casedocuments/$case_id/".$doc;
      mkdir($structures, 0755, true);
      
      $structuress = "casedocuments/$case_id/".$statid;
      mkdir($structuress, 0755, true);
      
        $case_document=$_FILES['dms_upl_doc']['name'];
        $tmp=$_FILES['dms_upl_doc']['tmp_name'];
        move_uploaded_file($tmp,"$structure/$case_document");
        $up_case="$structure/$case_document";

        
        $case_documents=$_FILES['dms_upl_doc']['name'];
        $tmp1=$_FILES['dms_upl_doc']['tmp_name'];
        move_uploaded_file($tmp1,"$structures/$case_documents");
        
        $case_documentss=$_FILES['dms_upl_doc']['name'];
        $tmp2=$_FILES['dms_upl_doc']['tmp_name'];
        move_uploaded_file($tmp2,"$structuress/$case_documentss");
        
        $query="select * from dms_case where id='".$_POST['id']."'";
        $num=get_num_rows($query);
        
        //$date=date("Y-m-d");
    $query=("insert into dms_case (case_id,dms_case_name,dms_client_fname,dms_client_lname,dms_company_name,dms_case_reg_date,dms_nxt_trial,dms_opp_fname,dms_opp_lname,dms_opp_law_name,dms_upl,doc_id,statid,dms_cre_date,dms_comment)values('$case_id','$_REQUEST[dms_case_name]','$_REQUEST[dms_client_fname]','$_REQUEST[dms_client_lname]','$_REQUEST[dms_company_name]','$_REQUEST[dms_case_reg_date]','$_REQUEST[dms_nxt_trial]','$_REQUEST[dms_opp_fname]','$_REQUEST[dms_opp_lname]','$_REQUEST[dms_opp_law_name]','$up_case','$doc','$statid','$_REQUEST[dms_cre_date]',
    '$_REQUEST[dms_comment]')");
        //echo $query;
        //exit;
        $query_where="";
        
    }

    else

    {        
    
    $case_id=$_REQUEST['case_id'];
    $doc=$_REQUEST['doc_id'];
    $statid=$_REQUEST['statid'];
  
    $structure = 'casedocuments/'.$case_id;
    mkdir($structure, 0755, true);
    
    $structures = "casedocuments/$case_id/".$doc;
    mkdir($structures, 0755, true);
    
    $structuress = "casedocuments/$case_id/".$statid;
    mkdir($structuress, 0755, true);
    
    $case_document=$_FILES['dms_upl_doc']['name'];
    $tmp=$_FILES['dms_upl_doc']['tmp_name'];
    move_uploaded_file($tmp,"$structure/$case_document");
    $up_case="$structure/$case_document";

      
    $case_documents=$_FILES['dms_upl_doc']['name'];
    $tmp1=$_FILES['dms_upl_doc']['tmp_name'];
    move_uploaded_file($tmp1,"$structures/$case_documents");
    
    $case_documentss=$_FILES['dms_upl_doc']['name'];
    $tmp2=$_FILES['dms_upl_doc']['tmp_name'];
    move_uploaded_file($tmp2,"$structuress/$case_documentss");
        
    
$query="update dms_case set case_id='$case_id',dms_case_name='$_REQUEST[dms_case_name]',dms_client_fname='$_REQUEST[dms_client_fname]',dms_client_lname='$_REQUEST[dms_client_lname]',dms_company_name='$_REQUEST[dms_company_name]',dms_case_reg_date='$_REQUEST[dms_case_reg_date]',dms_nxt_trial='$_REQUEST[dms_nxt_trial]',dms_opp_fname='$_REQUEST[dms_opp_fname]',dms_opp_lname='$_REQUEST[dms_opp_lname]',dms_opp_law_name='$_REQUEST[dms_opp_law_name]',dms_upl='$up_case',doc_id='$doc',statid='$statid',dms_cre_date='$_REQUEST[dms_cre_date]',dms_comment='$_REQUEST[dms_comment]' where id='".$_POST['id']."'";

        $query_where="";
    }

    query($query);

    if(!isset($_POST['id']))
    {
        header("Location: newcase.php");
    }
    else
        header("Location: newcase.php?msg");

}
//function for sarch and display paging
function datalist()

{  // $start=0;
    //$per_page=1;

Here my table view Query

  [COLOR=#ff0000]  $query="select dms_case.*,users_permission.user_view_status "." from dms_case, users_permission "." where dms_case.case_id = users_permission.userper_caseid and user_view_status='1'";[/COLOR]
    
    $where="";
    
    if(isset($_REQUEST['search']) )
    {
        $where="and case_id like '%".trim($_REQUEST['search'])."%' or  dms_case_name like '%".trim($_REQUEST['search'])."%'";
        $strGet="name=".$_REQUEST['search']."";
    }
    
    $query=$query.$where;

    if(isset($_GET['sort_method']))
    {
        $query.=" order by ".$_GET['sort_by']." ".$_GET['sort_method']."";
        $strGet="sort_by=".$_GET['sort_by']."&sort_method=".$_GET['sort_method']."";
    }
    $rs=get_rsltset(getPagingQuery($query, $itemPerPage = 5));

    $paging['paging']=getPagingLink($query,5,$strGet);

    array_push($rs,$paging['paging']);

    return $rs;
}

//function for edit
function editdata()

{

    $query="select * from dms_case where id='".base64_decode(base64_decode($_GET['id']))."'";

    return get_rsltset($query);

}
//function for delete
function Deletedata()

{

    $rs=get_rsltset("select * from dms_case where id ='".$_GET['id']."'");
    $query="delete from dms_case where id='".$_GET['id']."'";
    query($query);
    header("Location: newcase.php");    
}    

//delete folder

//end case
}
?>

Display NewCase:View:

<?

session_start();
ob_start();

include ‘classes/user.class.php’;

    //$cse_id=$data[$i]['case_id'];
    //case add 
$selcusercase="select * from users_permission where username='".$_SESSION['user_name']."'";
$caseselect=mysql_query($selcusercase);
$fetscaseper=mysql_fetch_assoc($caseselect);

$case_add=$fetscaseper['case_add'];
//$case_edit=$fetscaseper['case_edit'];
//$case_delete=$fetscaseper['case_delete'];

//file permission
//$selcusercaseid=“select * from fileper where username='”.$_SESSION[‘user_name’].“'”;
//$caseidselect=mysql_query($selcusercaseid);
//$fetscaseidper=mysql_fetch_assoc($caseidselect);

//$inco_type=$fetscaseidper[‘inco_type’];

//chkPrevilleges3();
$user=new User;

//data display
$data=$user->datalist();
$paging=$data[count($data)-1];
array_pop($data);

//edit
if(isset($_GET[‘action’]))
{
if($_GET[‘action’] ==“edit”)
{
$data=$user->editdata();
}
}

//form submit
if(isset($_POST[“Submit”]) || isset($_POST[“Submit_x”]))
{

$user-&gt;newcase();

}

//delete
if(isset($_GET[‘action’]))
{
if($_GET[‘action’] ==“delete”)
{
$user->Deletedata();
}
}

?>

<body id=“homepage” >

  &lt;div id="header"&gt;
  &lt;?php include('designs/header1.php');?&gt;

</div>

<!-- Top Breadcrumb Start –>
<!-- Top Breadcrumb End –>

<!-- Right Side/Main Content Start –>
<div id=“rightside”>
<div>

  &lt;!-- Content Box Start --&gt;

<div class=“contentcontainer”>

Here Condition For Insert:

<? if($case_add===‘0’ || is_null($case_add) || empty($case_add) || $_GET[‘action’]==“edit”) { ?>

&lt;div class="headings altheading"&gt;
             &lt;h2&gt;Add New Case&lt;/h2&gt;
&lt;/div&gt;
        &lt;div class="contentbox"&gt;
        
      &lt;form action="" name="forfm1" id="forfm1" method="post" enctype="multipart/form-data" onsubmit="return checkForm1(forfm1);"&gt;
          &lt;table width="100%" border="0" class="gridtable"&gt;
            
            &lt;tbody&gt;
             &lt;tr&gt;
                &lt;td width="50%" class="header"&gt;Case Id :&lt;/td&gt;                
                &lt;td width="50%"&gt;
           
                  &lt;input type="text" name="case_id" id="case_id" value="&lt;?php if($_GET['action']=="edit") echo $data[0]['case_id'];?&gt;" /&gt;
                  &lt;div id="status"&gt;&lt;/div&gt;
                                  &lt;/td&gt;
              &lt;/tr&gt;
              &lt;tr&gt;
                &lt;td width="50%" class="header"&gt;Case Name :&lt;/td&gt;                
                &lt;td width="50%"&gt;
                  &lt;input type="text" name="dms_case_name" id="dms_case_name" value="&lt;?php if($_GET['action']=="edit") echo $data[0]['dms_case_name'];?&gt;"/&gt;
                                &lt;/td&gt;
              &lt;/tr&gt;
              
              &lt;tr&gt;
                &lt;td class="header"&gt;Client First Name :&lt;/td&gt;
                &lt;td&gt;&lt;input type="text" name="dms_client_fname" id="dms_client_fname" value="&lt;?php if($_GET['action']=="edit") echo $data[0]['dms_client_fname'];?&gt;"/&gt;&lt;/td&gt;
              &lt;/tr&gt;
              
              &lt;tr&gt;
                &lt;td class="header"&gt;Client Last Name :&lt;/td&gt;
                &lt;td&gt;&lt;input type="text" name="dms_client_lname" id="dms_client_lname" value="&lt;?php if($_GET['action']=="edit") echo $data[0]['dms_client_lname'];?&gt;"/&gt;                    &lt;/td&gt;
              &lt;/tr&gt;
              
              &lt;tr&gt;
                &lt;td class="header"&gt;Client Company Name :&lt;/td&gt;
                &lt;td&gt;&lt;input type="text" name="dms_company_name" id="dms_company_name" value="&lt;?php if($_GET['action']=="edit") echo $data[0]['dms_company_name'];?&gt;"/&gt;&lt;/td&gt;
              &lt;/tr&gt;
              
              &lt;tr&gt;
                &lt;td class="header"&gt;Case Registration Date :&lt;/td&gt;
                &lt;td&gt;&lt;input type="text" name="dms_case_reg_date" id="dms_case_reg_date" value="&lt;?php if($_GET['action']=="edit") echo $data[0]['dms_case_reg_date'];?&gt;"/&gt;&lt;/td&gt;
              &lt;/tr&gt;
              
               &lt;tr&gt;
                &lt;td class="header" &gt;Case Next Trial or Pleading :&lt;/td&gt;
                &lt;td &gt;&lt;input type="text" name="dms_nxt_trial" id="dms_nxt_trial" value="&lt;?php if($_GET['action']=="edit") echo $data[0]['dms_nxt_trial'];?&gt;"/&gt;&lt;/td&gt;
              &lt;/tr&gt;
              
              &lt;tr&gt;
                &lt;td class="header"&gt;Opponent First Name :&lt;/td&gt;
                &lt;td&gt;&lt;input type="text" name="dms_opp_fname" id="dms_opp_fname" value="&lt;?php if($_GET['action']=="edit") echo $data[0]['dms_opp_fname'];?&gt;"/&gt;&lt;/td&gt;
              &lt;/tr&gt;
              
              &lt;tr&gt;
                &lt;td class="header"&gt;Opponent Last Name :&lt;/td&gt;
                &lt;td&gt;&lt;input type="text" name="dms_opp_lname" id="dms_opp_lname" value="&lt;?php if($_GET['action']=="edit") echo $data[0]['dms_opp_lname'];?&gt;"/&gt;&lt;/td&gt;
              &lt;/tr&gt;
              
              &lt;tr&gt;
                &lt;td class="header"&gt;Opponent Lawyer Name :&lt;/td&gt;
                &lt;td&gt;&lt;input type="text" name="dms_opp_law_name" id="dms_opp_law_name" value="&lt;?php if($_GET['action']=="edit") echo $data[0]['dms_opp_law_name'];?&gt;"/&gt;&lt;/td&gt;
              &lt;/tr&gt;
              
              &lt;tr&gt;
                &lt;td class="header"&gt;Upload Document :&lt;/td&gt;
                &lt;td&gt;
                 &lt;input type="file" name="dms_upl_doc" id="dms_upl_doc"  value="&lt;?php if($_GET['action']=="edit") echo $data[0]['dms_upl'];?&gt;"  /&gt; &lt;label&gt;
                  &lt;input type="hidden" name="doc_id" id="doc_id" value="&lt;?php if($_GET['action']=="edit") echo $data[0]['doc_id'];?&gt;" /&gt;
                  &lt;/label&gt;
                  &lt;label&gt;
                  &lt;input type="hidden" name="statid" id="statid" value="&lt;?php if($_GET['action']=="edit") echo $data[0]['statid'];?&gt;" /&gt;
                  &lt;/label&gt;                     &lt;/td&gt;
              &lt;/tr&gt;
              
              &lt;tr&gt;
                &lt;td class="header"&gt;Created Date :&lt;/td&gt;
       &lt;td&gt;&lt;input type="text" name="dms_cre_date" id="dms_cre_date" value="&lt;?php if($_GET['action']=="edit") { echo $data[0]['dms_cre_date']; } else { echo date("Y-m-d"); }?&gt;" readonly="readonly"/&gt;&lt;/td&gt;
              &lt;/tr&gt;
              
              &lt;tr&gt;
                &lt;td class="header"&gt;Comment :&lt;/td&gt;
                &lt;td&gt;
                  &lt;textarea name="dms_comment" cols="20" rows="3" id="dms_comment"&gt;&lt;?php if($_GET['action']=="edit") echo $data[0]['dms_comment'];?&gt;&lt;/textarea&gt; &lt;/td&gt;
              &lt;/tr&gt;
              
              &lt;tr&gt;
              &lt;td class="header"&gt;&nbsp;&lt;/td&gt;
              &lt;td&gt;
               &lt;div align="left"&gt;
                    &lt;?php if($_GET['action']=="edit") { ?&gt;
                       &lt;INPUT name="Submit" type="submit" class="submit" value="Update"&gt;
                       
        &lt;input type="hidden" name="id" value="&lt;?php  echo base64_decode(base64_decode($_GET['id'])); ?&gt;" &gt;

        &lt;?php } else  { ?&gt;
        &lt;input name="Submit" class="submit" value="Add New"  type="image" src="images/add_new.png" id="Submit" /&gt;
        &lt;?php } ?&gt;
          &lt;/div&gt;&lt;/td&gt;
       &lt;/tr&gt;
            &lt;tbody&gt;
            &lt;/tbody&gt;
          &lt;/table&gt;
       &lt;/form&gt;
         &lt;? } ?&gt;

<?php if($_GET[‘action’]!=“edit”) { ?>
<div style=“clear: both;”></div>
</div>
</div>
<!-- Content Box End –>

     &lt;!-- Graphs Box Start --&gt;

<!-- Graphs Box End –>

  &lt;!-- Alternative Content Box Start --&gt;

<div class=“contentcontainer”>
<div class=“extrabottom”>

&lt;/div&gt;
        &lt;div class="headings altheading"&gt;
            &lt;h2&gt;New Case &lt;/h2&gt;
        &lt;/div&gt;
        &lt;div class="contentbox"&gt;
          &lt;table width="113%" id="delTable"&gt;
            &lt;thead&gt;
              &lt;tr&gt;
                &lt;th &gt;S No.&lt;/th&gt;
                 &lt;th &gt;Case Id&lt;/th&gt;
                &lt;th &gt;Case Name&lt;/th&gt;                   
                &lt;th &gt;Client Name&lt;/th&gt;                  
                &lt;th &gt;Client Company Name&lt;/th&gt;
                &lt;th &gt;Case Registration Date&lt;/th&gt;
                &lt;th&gt;Case Next Trial or Pleading&lt;/th&gt;
                &lt;th &gt;Opponent Name&lt;/th&gt;               
                &lt;th &gt;Opponent Lawyer Name&lt;/th&gt;
                &lt;th &gt;Upload Document&lt;/th&gt;
               
                &lt;th &gt;Created Date&lt;/th&gt;
                &lt;th &gt;Comment&lt;/th&gt;
                &lt;th &gt;Actions&lt;/th&gt;
              &lt;/tr&gt;
            &lt;/thead&gt;
            
         &lt;?php if(count($data) &gt;=1) { for($i=0;$i&lt;count($data);$i++ ) { ?&gt;
            &lt;tbody&gt;
              &lt;tr id="&lt;?php echo $data[$i]['id'];?&gt;"&gt;
                &lt;td&gt;&lt;div align="left"&gt;&lt;?php echo $i+1; ?&gt;.&lt;/div&gt;&lt;/td&gt;
                &lt;td&gt;&lt;div align="left"&gt;&lt;?php echo $data[$i]['case_id'];?&gt;&lt;/div&gt;&lt;/td&gt;
                &lt;td&gt;&lt;div align="left"&gt;&lt;?php echo $data[$i]['dms_case_name'];?&gt;&lt;/div&gt;&lt;/td&gt;                    
                &lt;td&gt;&lt;div align="left"&gt;&lt;?php $a=$data[$i]['dms_client_fname'];$b=$data[$i]['dms_client_lname'];//echo $data[$i]['dms_client_lname'];
                $c=$a.$b;echo $c;?&gt;&lt;/div&gt;&lt;/td&gt;
               
                &lt;td&gt;&lt;div align="left"&gt;&lt;?php echo $data[$i]['dms_company_name'];?&gt;&lt;/div&gt;&lt;/td&gt;
                &lt;td&gt;&lt;div align="left"&gt;&lt;?php echo $data[$i]['dms_case_reg_date'];?&gt;&lt;/div&gt;&lt;/td&gt;
                &lt;td&gt;&lt;div align="left"&gt;&lt;?php echo $data[$i]['dms_nxt_trial'];?&gt;&lt;/div&gt;&lt;/td&gt;
                &lt;td&gt;&lt;div align="left"&gt;&lt;?php $d=$data[$i]['dms_opp_fname'];$e=$data[$i]['dms_opp_lname'];$f=$d.$e;echo $f;?&gt;&lt;/div&gt;&lt;/td&gt;
              
       &lt;td&gt;&lt;div align="left"&gt;&lt;?php echo $data[$i]['dms_opp_law_name'];?&gt;&lt;/div&gt;&lt;/td&gt;
       &lt;td&gt;&lt;div align="left"&gt;&lt;?php echo (basename ($data[$i]['dms_upl'],".php"));?&gt;&lt;/div&gt;&lt;/td&gt;
                
                 &lt;td&gt;&lt;div align="left"&gt;&lt;?php echo $data[$i]['dms_cre_date'];?&gt;&lt;/div&gt;&lt;/td&gt;
                &lt;td&gt;&lt;div align="left"&gt;&lt;?php echo $data[$i]['dms_comment'];?&gt;&lt;/div&gt;&lt;/td&gt;

Here Condition For Edit,Delete:
<?php
$cse_id=$data[$i][‘case_id’];
//case add edtit del
$selcusercase=“select * from users_permission where username='”.$_SESSION[‘user_name’].“’ and userper_caseid=‘$cse_id’”;
$caseselect=mysql_query($selcusercase);
$fetscaseper=mysql_fetch_assoc($caseselect);

                    $case_add=$fetscaseper['case_add'];
                    $case_edit=$fetscaseper['case_edit'];
                    $case_delete=$fetscaseper['case_delete'];
                    $case_view_status=$fetscaseper['user_view_status'];
                    $u_role=$fetscaseper['u_role'];

                ?&gt;
                 
                &lt;td&gt;&lt;? if($case_edit ==='0' || is_null($case_edit) || empty($case_edit) || $case_view_status === '0')    { ?&gt;&lt;a href="newcase.php?action=edit&id=&lt;?php echo base64_encode(base64_encode($data[$i]['id']));?&gt;" &gt;&lt;img src="index_files/icon_edit.png" alt="Edit" /&gt;&lt;/a&gt;&lt;? }  if($case_delete==='0' || is_null($case_delete) || empty($case_delete) || $case_view_status ==='0') {?&gt;&lt;a href="javascript:void(0);" class="delete" title="Delete User"&gt; &lt;img src="index_files/icon_delete.png" alt="Delete" /&gt;&lt;/a&gt; &lt;? } ?&gt; &lt;/td&gt;               
           &lt;/tr&gt;
               &lt;?php } } else  { ?&gt;
              
            &lt;tr&gt;
              &lt;td colspan="17"&gt;No Records Found&lt;/td&gt;
           &lt;/tr&gt;
                   

  &lt;?php } ?&gt;
  &lt;tr&gt;
              &lt;td colspan="17"&gt;&lt;div align="center"&gt;&lt;span class="style1"&gt;Pages&lt;/span&gt; : 
                &lt;?php if(empty($paging)) echo "1"; else echo $paging; ?&gt;
              &lt;/div&gt;&lt;/td&gt;
            &lt;/tr&gt;  
            &lt;tbody&gt;
            &lt;/tbody&gt;
          &lt;/table&gt;
        &lt;? } ?&gt;
        &lt;div style="clear: both;"&gt;&lt;/div&gt;
          
        &lt;/div&gt;

</div>
<!-- Alternative Content Box End –>
<div style=“clear: both;”></div>

    &lt;!-- Content Box Start --&gt;
    &lt;div class="contentcontainer"&gt;&lt;/div&gt;
&lt;!-- Content Box End --&gt;
     &lt;div id="footer"&gt;&lt;?php include('designs/footer.php');?&gt;&lt;/div&gt; 

</div>
</div>

&lt;div id="leftside"&gt;

<div class=“user”>
<?php include(‘designs/user.php’);?>
</div>
<div><?php include(‘treee.php’); ?></div>
</div>
<!-- Left Dark Bar End –>

&lt;!-- Notifications Box/Pop-Up Start --&gt; 

&lt;!-- Notifications Box/Pop-Up End --&gt; 

&lt;script type="text/javascript" src="index_files/enhance.js"&gt;&lt;/script&gt;    
&lt;script type="text/javascript" src="index_files/excanvas.js"&gt;&lt;/script&gt;
&lt;script type="text/javascript" src="index_files/jquery.js"&gt;&lt;/script&gt;
&lt;script type="text/javascript" src="index_files/jquery-ui.js"&gt;&lt;/script&gt;
&lt;script type="text/javascript" src="index_files/jquery_002.js"&gt;&lt;/script&gt;
&lt;script type="text/javascript" src="index_files/visualize.js"&gt;&lt;/script&gt;
&lt;script type="text/javascript" src="index_files/functions.js"&gt;&lt;/script&gt;

&lt;!--[if IE 6]&gt;
&lt;script type='text/javascript' src='scripts/png_fix.js'&gt;&lt;/script&gt;
&lt;script type='text/javascript'&gt;
  DD_belatedPNG.fix('img, .notifycount, .selected');
&lt;/script&gt;
&lt;![endif]--&gt; 

</body>
</html>


$query="select dms_case.*,users_permission.user_view_status "." from dms_case, users_permission "." where dms_case.case_id = users_permission.userper_caseid and user_view_status='1'";

$where="";

if(isset($_REQUEST['search']) )
{
$where="and case_id like '%".trim($_REQUEST['search'])."%' or dms_case_name like '%".trim($_REQUEST['search'])."%'";
$strGet="name=".$_REQUEST['search']."";
}

$query=$query.$where;

// a line of debug
echo '<hr /> . '$query . '<hr />';


I think you have a problem with the generated sql statement because there is no space before your “and” – the first word in your $where variable.

You can test this by echoing the entire $query variable onto the page, copy/paste it directly into your sql management tool and see if it throws an error.

If this is the case then there are a couple of other things you could have done to find this kind of classic PHP/Mysql error yourself, variously:

– look in your sql logs at the last queries run

– when you write SQL statements use UPPERCASE for sql statements so you can more readily see the diffs between SQL and other strings.


$where=" AND case_id LIKE '%".trim($_REQUEST['search'])."%' 
            OR dms_case_name LIKE '%".trim($_REQUEST['search'])."%'";

– echo out the string, as I suggested.

– catch sql errors using [fphp]mysql_error[/fphp] and [fphp]mysql_errno[/fphp] echo them, fork your code - or log the errors to a file