I have a code for converting some database cells to comparing operators
but not so good. Could someone give me ideas or help me to shorten this code?

thanks a lot

PHP Code:
function comparing($temp$input$outcomeId$temp2=0){
    if(
$temp2==0){    
        if(
$temp['operator']==0)
            if(
$input['value']==$temp['value'])
               
$sql=insertAppender($sql$input['id'], $outcomeId);
        if(
$temp['operator']==2)
            if(
$input['value']<$temp['value'])
                
$sql=insertAppender($sql$input['id'], $outcomeId);
        if(
$temp['operator']==3)
            if(
$input['value']>$temp['value'])
                
$sql=insertAppender($sql$input['id'], $outcomeId);
        if(
$temp['operator']==4)
            if(
$input['value']<=$temp['value'])
                
$sql=insertAppender($sql$input['id'], $outcomeId);
        if(
$temp['operator']==5)
            if(
$input['value']>=$temp['value'])
                
$sql=insertAppender($sql$input['id'], $outcomeId);
    }else{
        if(
$temp['operator']==2){
            if(
$temp2['operator']==3)
                if(
$input['value']<$temp['value']&&$input['value']>$temp2['value'])
                    
$sql=insertAppender($sql$input['id'], $outcomeId);
            if(
$temp2['operator']==5)
                if(
$input['value']<$temp['value']&&$input['value']>=$temp2['value'])
                    
$sql=insertAppender($sql$input['id'], $outcomeId);
        }
        if(
$temp['operator']==3){ 
            if(
$temp2['operator']==2)
                if(
$input['value']>$temp['value']&&$input['value']<$temp2['value'])
                    
$sql=insertAppender($sql$input['id'], $outcomeId);
            if(
$temp2['operator']==4)
                if(
$input['value']>$temp['value']&&$input['value']<=$temp2['value'])
                    
$sql=insertAppender($sql$input['id'], $outcomeId);
        }
        if(
$temp['operator']==4){ 
            if(
$temp2['operator']==3)
                if(
$input['value']<=$temp['value']&&$input['value']>$temp2['value'])
                    
$sql=insertAppender($sql$input['id'], $outcomeId);
            if(
$temp2['operator']==5)
                if(
$input['value']<=$temp['value']&&$input['value']>=$temp2['value'])
                    
$sql=insertAppender($sql$input['id'], $outcomeId);
        }
        if(
$temp['operator']==5){ 
            if(
$temp2['operator']==2)
                if(
$input['value']>=$temp['value']&&$input['value']<$temp2['value'])
                    
$sql=insertAppender($sql$input['id'], $outcomeId);
            if(
$temp2['operator']==4)
                if(
$input['value']>=$temp['value']&&$input['value']<=$temp2['value'])
                    
$sql=insertAppender($sql$input['id'], $outcomeId);
        }
    }                
     
mysql_query($sql);