Hi,

i'm doing a search system where you search the reference of a product and it shows a list of all results, but i have one prolem. Is that i can't do the seperation of the products by its material:

    $ref=$_GET['q2'];

    $query_prod="SELECT * FROM produtos WHERE referencia LIKE '%".$ref."%' ORDER BY ordem ASC";
    $produt=mysql_query($query_prod, $futura);
    $row_produt=mysql_fetch_assoc($produt);
    $count=mysql_num_rows($produt);  

    $query_idprod="SELECT * FROM produtos WHERE id_produto='".$row_produt['id_produto']."'";
    $idprod = mysql_query ($query_idprod, $futura);
    $row_idprod=mysql_fetch_assoc($idprod);

    $query_categ_list = "SELECT * FROM materiais WHERE id_material='".$row_idprod['id_material']."' ORDER BY ordem ASC";
    $categ_list = mysql_query($query_categ_list, $futura) or die(mysql_error());
    $row_material = mysql_fetch_assoc($categ_list);
    $totalRows_categ_list = mysql_num_rows($categ_list);

    $sel_categ="SELECT * FROM janelas";
    $categ=mysql_query($sel_categ,$futura);
    $row_categ=mysql_fetch_assoc($categ);

    $query_cores = "SELECT * FROM janelas WHERE id_categoria='".$row_categ['id_categoria']."'";
    $cores = mysql_query($query_cores, $futura) or die(mysql_error());
    $row_cores = mysql_fetch_assoc($cores);
    $totalRows_cores = mysql_num_rows($cores);

    $query_cores = "SELECT * FROM janelas WHERE id_categoria='".$row_categ['id_categoria']."'";
    $cores = mysql_query($query_cores, $futura) or die(mysql_error());
    $row_cores = mysql_fetch_assoc($cores);
    $totalRows_cores = mysql_num_rows($cores);


<?PHP

do{
?>
    <td width="631" valign="top" class="texto_pretobig2" style="padding-bottom:10px;"><div class="bomfundo" style="background-color:<?php echo $row_cores['cor']; ?>;">
        <table width="570" border="0" cellspacing="0" cellpadding="0">
            <strong>RESULTADOS DE PESQUISA ::</strong>
            <br/>
            <br/>
            <?php 
                do{
            ?>
                    <!--HERE IS WHERE I SAY WHAT IS THE MATERIAL-->
                    <tr>
                        <td colspan="2" class="div_topo">
                            <a name="cat<?php echo $row_material['id_material']; ?>"></a>  <strong>PRODUTOS :: <span class="texto2"><?php echo $row_material['material']; ?></span></strong>
                        </td>
                    </tr>

                    <tr>
                        <td colspan="2" height="16"></td>
                    </tr>

                    <?PHP
                        do{
                            $query_verimg = "SELECT * FROM produtos_img WHERE id_produto='".$row_produt['id_produto']."' ORDER BY default_ DESC";
                            $verimg = mysql_query($query_verimg, $futura) or die(mysql_error());
                            $row_verimg = mysql_fetch_assoc($verimg);

                    ?>
                    <tr>
                                    <td width="160" height="95" valign="top">
                                        <a href="ver_produto.php?id_produto=<?php echo $row_produt['id_produto']; ?>&id_categoria=<?php echo $row_produt['id_material']; ?>"><?php if($row_verimg['imagem']!="") { ?><img src="http://www.plasticos-futura.com/timthumb.php?src=http://www.plasticos-futura.com/produtos/<?php echo $row_verimg['imagem']; ?>&w=134px&h=98px&zc=1&q=100" width="134" height="98" style="border:1px solid #cccccc;" /><?php } else { ?><img src="imagens/futura.jpg" width="134" height="98" style="border:1px solid #cccccc;" /><?php } ?></a>
                                    </td>

                                    <td valign="top" class="texto_pretobig2">
                                        <strong>REFERÊNCIA: </strong><?php echo $row_produt['referencia']; ?><br />
                                        <strong>DESCRIÇÃO:</strong> <?php echo $row_produt['nome']; ?>
                                        <br/>
                                        <br/>
                                        <br/>
                                        <div id="a_img">
                                            <a href="ver_produto.php?id_produto=<?php echo $row_produt['id_produto']; ?>&id_categoria=<?php echo $row_produt['id_material']; ?>" class="a_img">Mais imagens</a>
                                        </div>
                                    </td>
                                </tr>

                                <tr>
                                    <td width="160" height="10" style="border-bottom:1px dashed #e0e0e0;"> </td>
                                    <td height="10" style="border-bottom:1px dashed #e0e0e0;"> </td>
                                </tr>


                                <tr>
                                    <td width="160" height="10"></td>
                                    <td height="10"></td>
                                </tr>

                            <?PHP                    
                        } while($row_produt = mysql_fetch_assoc($produt));
                } while ($row_material=mysql_fetch_assoc($categ_list));
            ?>
        </table>
Se não encontrar o produto que procura, por favor <a href="investigacao-desenvolvimento.php">contacte-nos</a>.
    </td>
<?PHP
} while($row_produt = mysql_fetch_assoc($produt));
?>

Recommended Answers

All 2 Replies

You mean your search is working fine, but you just need to arrange search result list.. Is it right??

Yes... can you help me with that?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.