0

Hi, Daniweb

I have this code that works like this: i search for a product and it gives me the name, reference and the image of the product found.
My problem is that the image doesn't appear.

 <?php 
        require_once('Connections/futura.php'); 
    ?>

    <?PHP
        $prod=$_GET['q2'];

        $sql_prod = "SELECT * FROM produtos WHERE nome LIKE '%".$prod."%' ORDER BY id_produto ASC";
        $res=mysql_query($sql_prod, $futura);
        $count=mysql_num_rows($res);


        $sql_img = "SELECT id_produto, imagem FROM produtos_img";
        $executa=mysql_query($sql_img, $futura);
    ?>
    <!--------------------------------------------------------------------------------------------------------->

    <!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=utf-8" />
    <link href="styles/style.css" rel="stylesheet" />
    <title>Plásticos Futura - Pesquisa</title>
    <link rel="shortcut icon" type="image/x-icon" href="imagens/plasticos.ico" />
    <script type="text/javascript" src="js/java.js"></script>
    </head>

    <body>
    <table width="1200" border="0" align="center" cellpadding="0" cellspacing="0" style="background-image:url(imagens/fundo5.jpg);background-repeat:repeat-y;">
    <tr>
    <td>
    <table width="1200" border="0" align="center" cellpadding="0" cellspacing="0" style="background-image:url(imagens/fundo3.jpg); background-repeat:no-repeat;" height="713" >
      <tr>
        <td height="60" valign="bottom"><?php include("topo.php"); ?></td>
      </tr>
      <tr>
        <td height="613" valign="top"><table width="1200" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td valign="top"><table width="260" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td align="right"><a href="index.php" title="Voltar à homepage"><img src="imagens/plasticos-futura.png" border="0" /></a></td>
              </tr>
              <tr>
                <td height="40"></td>
              </tr>
              <tr>
                <td><table width="250" border="0" align="right" cellpadding="0" cellspacing="0">
                  <tr>
                    <td width="30"></td>
                    <td height="26" class="menu" onclick="window.location='index.php'"><a href="index.php" title="Home - Plásticos Futura" class="menu_text">Home</a></td>
                  </tr>
                  <tr>
                    <td height="2"></td>
                    <td height="2"></td>
                  </tr>
                  <tr>
                    <td width="30"></td>
                    <td height="26" class="menu" onclick="window.location='empresa.php'"><a href="empresa.php" class="menu_text" title="Empresa - Plásticos Futura">Empresa</a></td>
                  </tr>
                  <tr>
                    <td height="2"></td>
                    <td height="2"></td>
                  </tr>
                  <tr>
                    <td width="30"></td>
                    <td height="26" class="menu" onclick="window.location='produtos.php'"><a href="produtos.php" class="menu_text" title="Produtos - Plásticos Futura">Produtos</a></td>
                  </tr>
                  <tr>
                    <td height="2"></td>
                    <td height="2"></td>
                  </tr>
                  <tr>
                    <td width="30"></td>
                    <td height="26" class="menu" onclick="window.location='noticias.php'"><a href="noticias.php" class="menu_text"  title="Notícias - Plásticos Futura">Notícias</a></td>
                  </tr>
                   <tr>
                    <td height="2"></td>
                    <td height="2"></td>
                  </tr>
                  <tr>
                      <td width="30"></td>
                      <td height="26" class="menu" onclick="window.location='oportunidades-de-negocio.php'"><a href="oportunidades-de-negocio.php" class="menu_text"  title="Oportunidades de Negócio - Plásticos Futura">Oportun. Negócio</a></td>
                    </tr>
                    <tr>
                      <td height="2"></td>
                      <td height="2"></td>
                    </tr>
                  <tr>
                      <td width="30"></td>
                      <td height="26" class="menu" onclick="window.location='recrutamento.php'"><a href="recrutamento.php" class="menu_text"  title="Recrutamento - Plásticos Futura">Recrutamento</a></td>
                    </tr>
                    <tr>
                      <td height="2"></td>
                      <td height="2"></td>
                    </tr>
                  <tr>
                    <td width="30"></td>
                    <td height="26" class="menu" onclick="window.location='contactos.php'"><a href="contactos.php" class="menu_text"  title="Contactos - Plásticos Futura">Contactos</a></td>
                  </tr>
                </table></td>
              </tr>
            </table></td>


    <!---------------------------------------------------------------------------------------------------------> 
             <td width="638" valign="top" class="texto_pretobig2"><div class="bomfundo"><strong>RESULTADOS DA PESQUISA::</strong><br />
            <br/>

    <?PHP
            if($count==0)
            {
    ?>

            <strong>Não foram encontrados resultados!</strong>

    <?PHP
            }   
            else
            { 
                echo 'Encontrado(s) ' . $count . ' resultados de pesquisa com a palavra "'. $prod .'":';
                echo '<br/>';
    ?>

             <table width="570" border="0" cellspacing="0" cellpadding="0">
            <?PHP 
                $i=0;
                while ($linha = mysql_fetch_array($res))
                {
                    if ($i==0) 
                    { 
                        echo '<tr>'; 
                    }

                    echo '<td colspan="2" class="div_topo">';

                    while ($img = mysql_fetch_array($executa))
                    {
                        echo '<tr><td align="left"><img src="produtos/'.$executa['imagem'].'"></td></tr>';
                    }               
                    echo '<tr><td><strong>DESCRIÇÃO</strong>:'. $linha['nome']. '</td>';
                    echo '<td><strong>REFERÊNCIA</strong>:'. $linha['referencia']. '</td></tr>';
                    $i=$i+1;
                }
            ?>
            </table>
    <?PHP
        }
    ?>
    <!----------------------------------------------------------------------------------------------------------------------->
     </div></td>
            <td width="178"></td>
          </tr>
        </table></td>
      </tr>
      <tr>
        <td height="40"><?php include("rodape.php"); ?></td>
      </tr>
    </table>
    </td>
      </tr>
      </table>
    </body>
    </html>

can someone help me, please?

Thank you,
PF2G

2
Contributors
1
Reply
2
Views
5 Years
Discussion Span
Last Post by joehms22
0

How are you storing the images in the database? If they are just under the subdir, this should work, but if they are something like Base64, you'll need to use the data: uri format.

Try doing a source view on your page to see exactly what is being output by the $img variable, perhaps it isn't what you want, but without your DB schema here I can't tell for sure.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.