how to display AND and OR conditions IN QUERY

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ditditsasa
    New Member
    • Mar 2012
    • 17

    how to display AND and OR conditions IN QUERY

    MY CODE FOR THIS IS CORRECT?TELL ME

    Code:
    function fetchCancel_noshow( $from_date, $to_date, $patient_id = null, $provider_id = null, $apptstatus_id = null )
    {
    
    	$where = "";
    	if ( $provider_id ) {
    	$where .= " AND e.pc_aid = '$provider_id'";
    	if ( $patient_id )  {
    		$where .= " AND e.pc_pid = '1'";
    		
    		$apptstatus_filter = " AND e.pc_apptstatus = ('!' OR '@')";
    		$where .= $apptstatus_filter;
    		} 
    	else {
    		$where .= " AND e.pc_pid != ''";
    		} 
    		}
    		$apptstatus_filter = " AND (e.pc_apptstatus ='!' OR e.pc_apptstatus ='@')";
    		$where .= $apptstatus_filter;
    							
    	$appointments = fetchEvents( $from_date, $to_date, $where );
    	return $appointments;
    }
    THANKYOU IN ADVANCE
    Last edited by Rabbit; Jun 12 '12, 03:15 PM. Reason: Please use code tags when posting code.
  • Rabbit
    Recognized Expert MVP
    • Jan 2007
    • 12517

    #2
    Please use code tags when posting code.

    You're the one that has to tell us if your code is correct or not. We don't know your business requirements, so there's no way for us to know. And if it's incorrect, you have to tell us what is incorrect. What is it doing that it's not supposed to and vice versa. What are the error codes and messages that you're getting?

    Comment

    Working...