Dynamic search like php and SQL Server does not work?

0

I'm having problems with a part of the code ...

I have 5 fields to be searched with input, and they make a call in the database and complete with their data ...

But of these 5 fields, 2 are not bringing any results! Please help me !!!

Select code with echo from table:

$sql = "SELECT 
    numero AS NUMERO,
    parcli.descricao AS DESCRIÇÃO,
    (SELECT top 1 db.cli.descricao
        FROM db.cli, db.out 
        WHERE outseq = prosequen
            AND outcliseq = clisequen
        ORDER BY outposica desc
    ) as OUTRA_PARTE,
    ISNULL(
        (SELECT db.cli.descricao + ' / ' AS [text()] FROM db.cli, db.PROPRA WHERE PRAPROSEQ = PROSEQUEN AND PRAADVSEQ = db.cli.CLISEQUEN AND db.cli.CLIADVTIP = 1 ORDER BY db.cli.descricao FOR XML PATH('')),' -'
    ) AS ADVOGADOS,
    ISNULL(ctrdescri ,'-') as CONTRATO
    FROM db.propro
        LEFT JOIN db.proprc on prcproseq = prosequen
        LEFT JOIN db.cli parcli on prcclnseq = parcli.clisequen 
        LEFT JOIN db.timctr on prcctrseq = ctrsequen
    WHERE protiposs = 1
        AND proencerr = 2
        AND numero like '%".utf8_decode($_POST['numero']). "%'
        AND descricao like '%".utf8_decode($_POST['parte'])."%'
        AND descricao like '%".utf8_decode($_POST['outra'])."%'
        AND descricao like '%".utf8_decode($_POST['nome'])."%'
        AND ctrdescri like '%".utf8_decode($_POST['contrato'])."%' 
    ";

   $stmt = sqlsrv_query( $conexion, $sql );

-

while($escrever=sqlsrv_fetch_array($stmt, SQLSRV_FETCH_NUMERIC)){           

    echo'<tr>
        <td style="font-family: Arial, sans-serif; font-size: 14px; padding: 10px 5px; overflow: hidden; word-break: normal; color: #333; background-color: #f0f0f0; ; vertical-align: top; border: 1px solid #aaa;">'.utf8_encode($escrever[0]).'</td>
        <td style="font-family: Arial, sans-serif; font-size: 14px; padding: 10px 5px; background-color: #f0f0f0; ; vertical-align: top; border: 1px solid #aaa; width: 14%;">'.utf8_encode($escrever[1]).'</td>
        <td style="font-family: Arial, sans-serif; font-size: 14px; padding: 10px 5px; overflow: hidden; word-break: normal; color: #333; background-color: #f0f0f0; ; vertical-align: top; border: 1px solid #aaa;">'.utf8_encode($escrever[2]).'</td>
        <td style="font-family: Arial, sans-serif; font-size: 14px; padding: 10px 5px; overflow: hidden; word-break: normal; color: #333; background-color: #f0f0f0; ; vertical-align: top; border: 1px solid #aaa;">'.utf8_encode($escrever[3]).'</td>
        <td style="font-family: Arial, sans-serif; font-size: 14px; padding: 10px 5px; overflow: hidden; word-break: normal; color: #333; background-color: #f0f0f0; ; vertical-align: top; border: 1px solid #aaa;">'.utf8_encode($escrever[4]).'</td>

        </tr>';

    }
}

" In the "Name" and "Other" fields if I search on one of the two, it looks in the "part" column, so it is "lost" ...

obs: the table names are fictitious!

    
asked by anonymous 06.06.2017 / 19:42

0 answers