Jump to content

[Resolvido] Separação de produtos por materiais


Recommended Posts

Posted (edited)

Bom dia

Eu estou a tentar fazer procura por referencia de varios produtos, só que não me divide os produtos por materais, aparece o Material do 1º produto e aos outra não aparecem nada...

$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_categ_list = "SELECT * FROM materiais WHERE id_material='".$row_produt['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">
  <?php
do{
  ?>
 <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="		 </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_material = mysql_fetch_assoc($categ_list));
?>

Outro problema que gostaria de perguntar é quando não encontrar resultados aparecer "Não foram encontrados resultados!".

Será que me podem ajudar, sff?

Obrigado,

PF2G

Edited by scorch
Adicionado Geshi.
Posted

não foi a ti que disse para não usar do {} while() por causa dos casos de falta de registos ?????

1º - não tens qualquer tipo de código de separação por materiais ... como pretendes fazer essa separação ???

2º - usa um if ... a função mysql_num_rows da-te o número de registos do recordset

IRC : sim, é algo que ainda existe >> #p@p

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.