Jump to content
Fórum Script Brasil
  • 0

Erro ao buscar dados no banco de dados


Well_PHP

Question

Olá pessoal,

Estou com dificuldades para buscar o preço antigo e o preço atual:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
</head>
<body>
<div id="all">
    <div id="meio">
             <div class="content-titulo icon-titulo titulo-geral">Produtos</div>
             <form action="?" method="get">
                 <div id="divPesquisa">
                        <table border="0" width="100%" cellpadding="0" cellspacing="1">
                              <tr>
                                <td width="11%" class="td01">Nome:</td>
                                <td width="80%" class="td08"><input name="nome" type="text" class="input2" id="nome" onkeydown="EnviarPressEnter(event.keyCode);" size="45" align="middle" /></td>
                                <td width="6%" valign="middle"><div align="right">
                                  <input name="button2" type="button" class="botao02" onclick="vai('cadastrar.php')" value="Cadastrar" alt="Adicionar" />
                                </div></td>
                              </tr>
                              <tr>
                                <td colspan="2" class="td01">&nbsp;</td>
                                <td valign="middle"><div align="right">
                                  <input name="button22" type="button" class="botao02" onclick="Envia()" value="Pesquisar" alt="Incluir" />
                                </div></td>
                              </tr>
                           </table>
                  </div>
             </form>
             <div id="conteudo">
                <?php
                    
                    $campos    = array();
                    $nome     = strtoupper($_REQUEST['nome']);
                    if ($nome)        $campos[] = "upper(titulo) like '%".$nome."%'";
                    if($campos)
                        $resultado         = " where ".join(' AND ', $campos); 
                    
                    $sql                 = "select COUNT(*) as total  
                                           from ".PRODUTO." p
                                           $resultado 
                                           ";
                    $total_registro     = mysql_result($db->query($sql),0,"total");

                    $Paginacao = new Paginacao();
                    # Configuração dos elementos da classe Paginação 
                    $Paginacao->setTotal_registro($total_registro);
                    $sql                 = " select p.*, c.descricao categoria
                                            from ".PRODUTO." p 
                                            left join ".CATEGORIA." c using(id_categoria)
                                            inner join ".PRODUTO_ESTOQUE." pe on pe.id_produto = p.id_produto
                                            $resultado 
                                            group by p.id_produto
                                            order by titulo asc 
                                            limit ".$Paginacao->limit();
                                        
                    $result        = $db->query($sql);
                    
                    if(!$db->rows($result))
                       echo("<br><div class='mgsNenhumReg'>Nenhum Registro Encontrado!</div>");
                    else{
                ?>
                    <table  border="1" width="100%" bordercolor="#333333" cellpadding="0" cellspacing="2" id="large">
                  <thead>
                        <tr>
                          <td width="8%" height="25" valign="middle" class="td01"><div align="center">Codigo</div></td>
                          <td width="35%" height="18" valign="middle" class="td01">Titulo</td>
                            <td width="16%" class="td01"><label for="checkbox_row_8"> Categoria </label></td>
                            <td width="12%" valign="middle" class="td01"><div align="center">Pre&ccedil;o Antigo </div></td>
                          <td width="11%" valign="middle" class="td01"><div align="center">Pre&ccedil;o Atual </div></td>
                          <td width="5%" valign="middle" class="td01"><div align="center">Ativo</div></td>
                            <td width="6%" valign="middle" class="td01"><div align="center">Com</div></td>
                        </tr>
                    </thead>
                    <tfoot>
                    </tfoot>
                    <tbody>
                          <?php        
                               while($db->li = $db->fetch($result)){
                                   $uId                  = $db->li["id_produto"];
                                   $titulo_produto   = $db->li["titulo"];
                                   $codigo              = $db->li["codigo"];
                                   $vlr_atual        = $db->li["vlr_atual"];
                                   $vlr_antigo           = $db->li["vlr_antigo"];                   
                                   $categoria        = $db->li["categoria"];
                                   $ativo             = $db->li["status"];
                                   $qtd_estoque      = $db->li["qtd_estoque"];                   

                                   
                           ?>

                        <td height="25" class="<?php echo $cor?>" align="center"><?php echo $uId;?></td>
                                    <td height='15' class="<?php echo $cor?>"><?php echo $titulo_produto;?> </td>
                        <td align="left" class="<?php echo $cor?>"><a href="editar.php?uId=<?php echo $uId?>"> <?php echo $categoria;?></a></td>
                                    <td align="center" class="<?php echo $cor?>"><?php echo number_format($vlr_antigo,2,",",".");?></td>
                                    <td align="center" class="<?php echo $cor?>"><?php echo number_format($vlr_atual,2,",",".");?> </td>
                                    <td align="center" class="<?php echo $cor?>"><?php echo ($ativo ? "Sim": "Não");?> </td>
                                    <td height='15' class="<?php echo $cor?>" align="center">
                                        <img src='../../img/icons/16/edit.gif' alt='Alterar' width="16" height="16" border='0' align='middle' onclick="vai('editar.php?uId=<?php echo $uId?>')" class="linkImg"/>
                                        <img src='../../img/icons/16/editdelete.gif' alt='Excluir' width="16" height="16" border='0' align='middle' onclick="deletarRegistro('<?php echo $titulo_produto?>','<?php echo $uId;?>');" class="linkImg">
                        </td>
                                </tr>
                      <?php  }  ?>
                    </tbody>
                    </table>
               <?php  }  ?>
             
             </div>
 </div>
</body>
</html>

O retorno é 0,00 nos 2 campos.

Obrigado

Link to post
Share on other sites

2 answers to this question

Recommended Posts

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



  • Forum Statistics

    • Total Topics
      149287
    • Total Posts
      645679
×
×
  • Create New...