Doubt PHP + Sql server

Asked

Viewed 50 times

0

Good Afternoon everyone

I’m new to the forum so I don’t know if I’ve opened this topic in the right place.

I need a help in a table that I am generating with php through some queries being one in mysql, and from the result of it I perform another in a bd sql server using odbc_exec.

the table lists the products that are available production at the factory and search in the Rp database the total quantity of the product in stock( to help decide what will produce first) the problem is that for some products it brings the stock straight and for others not. I put to write the sql(from sql server) on the screen, copied the code and executed directly in the bd by ssms (SQL Server Management Studio) and brings the result normally. however if I run php, for some records it appears and for others it does not.

below follows the code:

       <table class="table table-responsive table-bordered table-striped table-hover table-condensed  lista-clientes">
            <thead>
                <tr>
                    <th>CORTE</th>
                    <th>GRUPO</th>
                    <th>SUBGRUPO</th>
                    <th>ESTAMPA</th>
                    <th>TAMANHO</th>
                   <th>DISPONIVEL</th>                    
                    <th>ESTOQUE</th>
                    <th>DISP. P/ PROD.</th>
                 </tr>
            </thead>
            <tbody>
<?php 
$sql="select * from corte where status='Novo'";

$executa=mysqli_query($link, $sql);

while($ROW= mysqli_fetch_assoc($executa)){ 

//BUSCA DADOS DO CORTE
    $SQL_DADOS_SEQUENCIAL="SELECT * FROM sequencial WHERE CORTE='".$ROW['CORTE']."'";
    $EXECUTA_DADOS_SEQUENCIAL=mysqli_QUERY($link,$SQL_DADOS_SEQUENCIAL);
    $RESULTADO_DADOS_SEQUENCIAL=mysqli_fetch_assoc($EXECUTA_DADOS_SEQUENCIAL);
//busca os dados do sequencial
$sql_busca_dados_corte="select * from sequencial where CORTE='".$ROW['CORTE']."'";
$executa_busca_corte=mysqli_query($link, $sql_busca_dados_corte);
$exibe_busca_corte=mysqli_fetch_assoc($executa_busca_corte);

//MONTA NOME DO PRODUTO
$ESPACO=" ";
$NOME_PRODUTO=$ROW['GRUPO'];
$NOME_PRODUTO.=$ESPACO;
$NOME_PRODUTO.=$ROW['SUBGRUPO'];
$NOME_PRODUTO.=$ESPACO;
$NOME_PRODUTO.= $RESULTADO_DADOS_SEQUENCIAL['cor_estampa'];

//busca o codigo do produto pelo nome cor e tamanho
$SQL_BUSCA_CODIGO="SELECT sum(c.ES3)as tam
FROM PRODUTOS A 
left JOIN PRODUTO_CORES B 
ON A.PRODUTO = B.PRODUTO
left join ESTOQUE_PRODUTOS c
ON A.PRODUTO = c.PRODUTO
WHERE A.DESC_PRODUTO LIKE'%".TRIM($NOME_PRODUTO)."%' AND B.COR_PRODUTO='".TRIM($RESULTADO_DADOS_SEQUENCIAL['tecido'])."'";
$resultado_BUSCA_CODIGO = odbc_exec($con_sql, $SQL_BUSCA_CODIGO);
echo "<tr>";
echo "<td>" . nl2br( $ROW['CORTE']) . "</td>"; 
echo "<td>" . nl2br( $ROW['GRUPO']) . "</td>"; 
echo "<td>" . nl2br( $ROW['SUBGRUPO']) . "</td>";  
echo "<td>" . nl2br( $exibe_busca_corte['cor_estampa']) . "</td>"; 

echo "<td>" . nl2br( $ROW['TAMANHO']) . "</td>";
echo "<td>" . nl2br( $ROW['QUANTIDADE']) . "</td>";
echo "<td>". odbc_result($resultado_BUSCA_CODIGO,"tam")."</td>";
echo "<td>" .  $SQL_BUSCA_CODIGO . "</td>";

}//fim while 


?>

        </tbody>
        </table>

I tried several solutions but could not, pf me help you guys

  • what the variable $resultado_BUSCA_CODIGO is returning to you ?

  • she makes the query inside the bd, then I use the function odbc_result to display

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.