0

Hi, i'm doing a table that show products that you search for...Now i have a proble with the image and the category of the product they don't appear in the page:

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

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

    $query_prod="SELECT * FROM produtos WHERE nome LIKE '%".$prod."%'";
    $produt=mysql_query($query_prod, $futura);
    $count=mysql_num_rows($produt);   


    $prod_img="SELECT * FROM produtos WHERE nome LIKE '%". $prod ."%'";
    $image=mysql_query($prod_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.' resultado(s) 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($image))
                        {
                            if ($i==0)
                            {
                                echo '<tr>';
                            }
                                //MATERIAL
                                $sel_mat="SELECT * FROM  materiais WHERE id_material = '".$linha['id_material']."'";
                                $mat=mysql_query($sel_mat, $futura);
                                echo '<td colspan="2" class="div_topo"> PRODUTOS:: '.$mat['material'];

                                //IMAGEM
                                $sel_img="SELECT * FROM  produtos_img WHERE id_produto = '".$linha['id_produto']."'";
                                $img=mysql_query($sel_img, $futura);
                                echo '<tr><td align="left"><img src="'.$img['imagem'].'"/></td></tr>';                        


                                echo '<tr><td align="left"><strong>DESCRIÇÃO</strong>:'. $linha['nome']. '</td>';
                                echo '<td align="left"><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

Edited by PF2G

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

The problem is in your while.

//IMAGEM $sel_img="SELECT * FROM produtos_img WHERE id_produto = '".$linha['id_produto']."'"; $img=mysql_query($sel_img, $futura); echo '<tr><td align="left"><img src="'.$img['imagem'].'"/></td></tr>';

You have to fetch your $sel_img query.

`$sel_img=mysql_query("SELECT * FROM  produtos_img WHERE id_produto = '".$linha['id_produto']."'");

`if(mysql_num_rows($sel_img) > 0)
{
        $img = mysql_fetch_array($sel_img);
        echo '<tr><td align="left"><img src="'.$img['imagem'].'"/></td></tr>';
}
else
{
    echo 'No images found.';
}`

Edited by Szabi Zsoldos

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.