Jump to content

Recommended Posts

Posted

Boas eu estou a tentar fazer um pedaço de codigo onde me lê a coluna prod_img(imagem grande)na tabela MySQL e no back-office pôr uma checkbox que se tiver checkada, no front-office aparece a tabela com as imagens grandes, se não estiver checkada aparece normal (tabela com info)...

Mas estou a ter problemas com o codigo no front-office, alguem me pode ajudar?

<?php require_once('Connections/futura.php'); ?>
<?php
set_time_limit(0);
include("incluir.php");

$query_categorias = "SELECT * FROM materiais ORDER BY ordem ASC";
$categorias = mysql_query($query_categorias, $futura) or die(mysql_error());
$row_categorias = mysql_fetch_assoc($categorias);
$totalRows_categorias = mysql_num_rows($categorias);

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

$query_categ_list = "SELECT * FROM materiais ORDER BY ordem ASC";
$categ_list = mysql_query($query_categ_list, $futura) or die(mysql_error());
$row_categ_list = mysql_fetch_assoc($categ_list);
$totalRows_categ_list = mysql_num_rows($categ_list);
?>
<!------------------------------------------------------------------------------>
<!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 rel="shortcut icon" type="image/x-icon" href="imagens/plasticos.ico" />
<link href="styles/style.css" rel="stylesheet" />
<title>Plásticos Futura - Produtos</title>
<script type="text/javascript" src="js/java.js"></script>
<script type='text/javascript' src='jquery/jquery.js'></script>
</head>
<!------------------------------------------------------------------------------>
<body>
<table width="1200" border="0" align="center" cellpadding="0" cellspacing="0" style="background-image:url(imagens/fundo7.jpg);background-repeat:repeat-y;">
 <tr>
  <td>
<table width="1200" border="0" align="center" cellpadding="0" cellspacing="0" style="background-image:url(imagens/fundo6.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" class="menu_text" title="Home - Plásticos Futura">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" title="Produtos - Plásticos Futura" class="menu_text"><strong>Produtos</strong></a></td>
		  </tr>
		  <tr>
		   <td height="2"></td>
		   <td height="2"></td>
		  </tr>

		  <?php do { ?>
		   <tr>
			<td width="30" height="18"></td>
			<td height="20" class="submenu2" onclick="window.location='#cat<?php echo $row_categorias['id_material']; ?>'"><a href="#cat<?php echo $row_categorias['id_material']; ?>" class="submenu_text"><?php echo $row_categorias['material']; ?></a></td>
		   </tr>

		   <tr>
			<td height="3"></td>
			<td height="3"></td>
		   </tr>
		  <?php } while ($row_categorias = mysql_fetch_assoc($categorias)); ?>


		  <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>

	 <!----------------------------------------------------------------------------------------------------->
	 <!--IMAGEM GRANDE ou INFO NORMAL-->
	 <td>
	  <?PHP
	   $query_produtos = "SELECT * FROM produtos WHERE id_material='".$row_categ_list['id_material']."' ORDER BY referencia ASC";
	   $produtos = mysql_query($query_produtos, $futura) or die(mysql_error());
	   $row_produtos = mysql_fetch_assoc($produtos);
	   $totalRows_produtos = mysql_num_rows($produtos);

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

	   $query_imgbig="SELECT * FROM produtos WHERE id_produto = ".$row_prdutos['id_produto'];
	   $big_img = mysql_query($query_imgbig, $futura);
		do
		{
	   ?>
		  <table width="570" border="0" cellspacing="0" cellpadding="0">
		  <tr>
		  <td width="160" height="95" valign="top">
		  <a href="ver_produto.php?id_produto=<?php echo $row_produtos['id_produto']; ?>&id_categoria=<?php echo $row_produtos['id_material']; ?>"><?php if($row_verimg['imagem']!="") { ?><img src="http://www.plasticos-futura.com/timthumb.php?<?php echo $row_verimg['imagem']?>"></a> </td>
		  </tr>
		  </table>
		 <?PHP
		 while ($big_img['prod_img']="sim");
		}

		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_categ_list['id_material']; ?>"></a>  <strong>PRODUTOS :: <span class="texto2"><?php echo $row_categ_list['material_en']; ?></span></strong></td>
			</tr>

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

			<tr>
			 <td width="160" height="95" valign="top">
			  <a href="ver_produto.php?id_produto=<?php echo $row_produtos['id_produto']; ?>&id_categoria=<?php echo $row_produtos['id_material']; ?>"><?php if($row_verimg['imagem']!="") { ?><img src="http://www.plasticos-futura.com/timthumb.php?src=<?php echo $row_verimg['imagem']; ?>"></a></td>

			 <td valign="top" class="texto_pretobig2"><strong>REFERÊNCIA: </strong><?php echo $row_produtos['referencia']; ?><br />
			  <strong>DESCRIÇÃO:</strong> <?php echo $row_produtos['nome']; ?>
			  <br/>
			  <br/>

			  <div id="a_img">
			   <a href="ver_produto.php?id_produto=<?php echo $row_produtos['id_produto']; ?>&id_categoria=<?php echo $row_produtos['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>
			<tr>
			 <td width="160" height="30"></td>
			 <td height="10" align="right"><a href="#topo" style="text-decoration:none;"><img src="imagens/arrow.gif" border="0" align="absmiddle" /> Topo da página</a> </td>
			</tr>
			<?php ;} while ($row_categ_list = mysql_fetch_assoc($categ_list)); ?>
		   </table>
		  </td>
		<?PHP   
		while ($img_big['prod_img']="não");}
		?> 
	 </td>
	<!----------------------------------------------------------------------------------------------------->
	 <td width="178"></td>
	</tr>
   </table>
  </td>
 </tr>

 <tr>
  <td height="46" style="background-image:url(imagens/fundo4.jpg); background-repeat:no-repeat"><?php include("rodape.php"); ?></td>
 </tr>
</table>
  </td>
 </tr>
</table>
</body>
</html>
Na coluna prod_img só aparece "sim" para checkbox checkada e "não" se não estiver checkada.
Posted

reparaste que o próprio geshi reclama do teu código certo ??? .. anda pr'ai umas aspas mal fechadas

Já esta tudo bem, sem erros só tem um problema é que aparece mais um produto, de lado, do que devia aparecer...

<?php require_once('Connections/futura.php'); ?>
<?php
set_time_limit(0);
include("incluir.php");

$query_categorias = "SELECT * FROM materiais ORDER BY ordem ASC";
$categorias = mysql_query($query_categorias, $futura) or die(mysql_error());
$row_categorias = mysql_fetch_assoc($categorias);
$totalRows_categorias = mysql_num_rows($categorias);
$query_cores = "SELECT * FROM janelas WHERE id_categoria='2'";
$cores = mysql_query($query_cores, $futura) or die(mysql_error());
$row_cores = mysql_fetch_assoc($cores);
$totalRows_cores = mysql_num_rows($cores);

$query_categ_list = "SELECT * FROM materiais ORDER BY ordem ASC";
$categ_list = mysql_query($query_categ_list, $futura) or die(mysql_error());
$row_categ_list = mysql_fetch_assoc($categ_list);
$totalRows_categ_list = mysql_num_rows($categ_list);
?>
<!------------------------------------------------------------------------------>
<!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 rel="shortcut icon" type="image/x-icon" href="imagens/plasticos.ico" />
<link href="styles/style.css" rel="stylesheet" />
<title>Plásticos Futura - Produtos</title>
<script type="text/javascript" src="js/java.js"></script>
<script type='text/javascript' src='jquery/jquery.js'></script>
</head>
<!------------------------------------------------------------------------------>
<body>
<table width="1200" border="0" align="center" cellpadding="0" cellspacing="0" style="background-image:url(imagens/fundo7.jpg);background-repeat:repeat-y;">
 <tr>
  <td>
   <table width="1200" border="0" align="center" cellpadding="0" cellspacing="0" style="background-image:url(imagens/fundo6.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" class="menu_text" title="Home - Plásticos Futura">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" title="Produtos - Plásticos Futura" class="menu_text"><strong>Produtos</strong></a></td>
		  </tr>
		  <tr>
		   <td height="2"></td>
		   <td height="2"></td>
		  </tr>

		  <?php do { ?>
		   <tr>
		    <td width="30" height="18"></td>
		    <td height="20" class="submenu2" onclick="window.location='#cat<?php echo $row_categorias['id_material']; ?>'"><a href="#cat<?php echo $row_categorias['id_material']; ?>" class="submenu_text"><?php echo $row_categorias['material']; ?></a></td>
		   </tr>

		   <tr>
		    <td height="3"></td>
		    <td height="3"></td>
		   </tr>
		  <?php } while ($row_categorias = mysql_fetch_assoc($categorias)); ?>


		  <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>

	 <!--------------------INICIO/IMAGEM_GRANDE---------------------->
	 <?php

	 do{
	  $sel_produtos = "SELECT * FROM produtos WHERE id_material='".$row_categ_list['id_material']."' ORDER BY referencia ASC";
	  $prods = mysql_query($sel_produtos, $futura) or die(mysql_error());
	  $row_prods = mysql_fetch_assoc($prods);
	  $total_prods = mysql_num_rows($prods);


	  $query_bimg = "SELECT * FROM produtos_img WHERE id_produto='".$row_prods['id_produto']."' ORDER BY default_ DESC";
	  $b_img = mysql_query($query_bimg, $futura) or die(mysql_error());
	  $total_prods = mysql_num_rows($prods);

	  if ($prods['prod_img']=="Sim")
	  {

	 ?>

	  <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">
	    <tr>
		 <td width="160" height="95" valign="top">

		  <a href="ver_produto.php?id_produto=<?php echo $row_produtos['id_produto']; ?>&id_categoria=<?php echo $row_produtos['id_material']; ?>"><?php if($row_verimg['imagem']!="") { ?><img 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="" height="98" style="border:1px solid #cccccc;" /><?php } ?></a>

		 </td>
	    </tr>
	   </table>
	  </td>

	 <?PHP
	  ;}
	  else
	  {
	 ?>
	 <!----------------------FIM/IMAGEM_GRANDE----------------------->

	 <!--------------------INICIO/TABELA_NORMAL---------------------->		
		 <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_categ_list['id_material']; ?>"></a>  <strong>PRODUTOS :: <span class="texto2"><?php echo $row_categ_list['material_en']; ?></span></strong></td>
			 </tr>

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

			 <?php
			  $query_produtos = "SELECT * FROM produtos WHERE id_material='".$row_categ_list['id_material']."' ORDER BY referencia ASC";
			  $produtos = mysql_query($query_produtos, $futura) or die(mysql_error());
			  $row_produtos = mysql_fetch_assoc($produtos);
			  $totalRows_produtos = mysql_num_rows($produtos);

			  do { 
			  $query_verimg = "SELECT * FROM produtos_img WHERE id_produto='".$row_produtos['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_produtos['id_produto']; ?>&id_categoria=<?php echo $row_produtos['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_produtos['referencia']; ?><br />
			  <strong>DESCRIÇÃO:</strong> <?php echo $row_produtos['nome']; ?>
			  <br/>
			  <br/>
			  <div id="a_img">
			   <a href="ver_produto.php?id_produto=<?php echo $row_produtos['id_produto']; ?>&id_categoria=<?php echo $row_produtos['id_material']; ?>" class="a_img">Mais imagens</a>
			  </div>

			  </td>
			   </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_produtos = mysql_fetch_assoc($produtos)); ?>


			 <tr>
			  <td width="160" height="30"></td>
			  <td height="10" align="right"><a href="#topo" style="text-decoration:none;"><img src="imagens/arrow.gif" border="0" align="absmiddle" /> Topo da página</a> </td>
			 </tr>
		    <?php } while ($row_categ_list = mysql_fetch_assoc($categ_list)); ?>
		  </table>
		 <!--</div>-->
		 </td>
	  <!----------------------FIM/TABELA_NORMAL----------------------->
	  <?PHP
	  ;}
	  } while ($total_prods = mysql_num_rows($prods));
	  ?>
	 <td width="178"></td>
    </tr>
   </table>
  </td>
 </tr>

 <tr>
  <td height="46" style="background-image:url(imagens/fundo4.jpg); background-repeat:no-repeat"><?php include("rodape.php"); ?></td>
 </tr>
   </table>
  </td>
 </tr>
</table>
</body>
</html>

e tenho um While mal feito, penso eu ,se me pudesses ajudar, agradecia:

<!----------------------FIM/TABELA_NORMAL----------------------->
	  <?PHP
	  ;} //fecha o "else"
	  } while ($total_prods = mysql_num_rows($prods));
	  ?>
Posted

Já adicionei na tabela prod_image="sim" para testar e não me escreve...

<!--------------------INICIO/IMAGEM_GRANDE---------------------->
	 <?php

	 do{
	  $sel_produtos = "SELECT * FROM produtos WHERE id_material='".$row_categ_list['id_material']."' ORDER BY referencia ASC";
	  $prods = mysql_query($sel_produtos, $futura) or die(mysql_error());
	  $row_prods = mysql_fetch_assoc($prods);
	  $total_prods = mysql_num_rows($prods);


	  $query_bimg = "SELECT * FROM produtos_img WHERE id_produto='".$row_prods['id_produto']."' ORDER BY default_ DESC";
	  $b_img = mysql_query($query_bimg, $futura) or die(mysql_error());
	  $total_prods = mysql_num_rows($prods);

	  if ($prods['prod_img']=="Sim")
	  {		  
	   ECHO 'TA A FUNCIONAR';
	  ;}
	  else
	  {
	 ?>
	 <!----------------------FIM/IMAGEM_GRANDE----------------------->

	 <!--------------------INICIO/TABELA_NORMAL---------------------->		
		 <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_categ_list['id_material']; ?>"></a>  <strong>PRODUTOS :: <span class="texto2"><?php echo $row_categ_list['material_en']; ?></span></strong></td>
			 </tr>

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

			 <?php
			  $query_produtos = "SELECT * FROM produtos WHERE id_material='".$row_categ_list['id_material']."' ORDER BY referencia ASC";
			  $produtos = mysql_query($query_produtos, $futura) or die(mysql_error());
			  $row_produtos = mysql_fetch_assoc($produtos);
			  $totalRows_produtos = mysql_num_rows($produtos);

			  do { 
			  $query_verimg = "SELECT * FROM produtos_img WHERE id_produto='".$row_produtos['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_produtos['id_produto']; ?>&id_categoria=<?php echo $row_produtos['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_produtos['referencia']; ?><br />
			  <strong>DESCRIÇÃO:</strong> <?php echo $row_produtos['nome']; ?>
			  <br/>
			  <br/>
			  <div id="a_img">
			   <a href="ver_produto.php?id_produto=<?php echo $row_produtos['id_produto']; ?>&id_categoria=<?php echo $row_produtos['id_material']; ?>" class="a_img">Mais imagens</a>
			  </div>

			  </td>
			   </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_produtos = mysql_fetch_assoc($produtos)); ?>


			 <tr>
			  <td width="160" height="30"></td>
			  <td height="10" align="right"><a href="#topo" style="text-decoration:none;"><img src="imagens/arrow.gif" border="0" align="absmiddle" /> <font size="3">Topo da página</font></a> </td>
			 </tr>
		    <?php } while ($row_categ_list = mysql_fetch_assoc($categ_list)); ?>
		  </table>
		 </td>
	  <!----------------------FIM/TABELA_NORMAL----------------------->
	  <?PHP
	  ;}
	  } while ($row_produtos = mysql_fetch_assoc($produtos));
	  ?>
Posted

poeds publicar uma imagem do resultado ... o que dizes e muito confuso

Esse é o código que tenho.

Eu adicionei "Sim" ao prod_img para testar se estava a funcionar e não me aparece o echo.

PS: prod_img (coluna onde diz se a checkbox que se situa no backoffice está checkada ou não. Se tiver checkada o resultado é Sim se não estiver o resultado é Não).

Fui claro?

Posted

Não tanto.

Esse código com essa indentação é difícil de ler. N tenho cabeça para conseguir ler isso. Nem sei se consigo dar-me ao trabalho de ler...

Correge a indentação, se queres a minha ajuda.

"[Os jovens da actual geração]não lêem porque não envolve um telecomando que dê para mirar e atirar, não falam porque a trapalhice é rainha e o calão é rei" autor: thoga31

Life is a genetically transmitted disease, induced by sex, with death rate of 100%.

Posted

Bom dia,

Depois de várias tentativas e confusões consegui o que queria (mais ou menos), o bom é que não tenho nenhum erro, o problema é que não me lê a coluna img_grande direito:

<!--------------------------------------begin/IMAGEM-GRANDE-------------------------------------->
<?PHP
$sql_produtos = "SELECT * FROM produtos WHERE img_grande = 'Sim'";
$prods = mysql_query($sql_produtos, $futura) or die(mysql_error());
$row_prods = mysql_fetch_assoc($prods);
$totalRows_prods = mysql_num_rows($prods);
var_dump($prods['img_grande']=='Sim');exit;
if ($prods['img_grande']=='Sim')
{
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_categ_list['id_material']; ?>"></a>  <strong>PRODUTOS :: <span class="texto2"><?php echo $row_categ_list['material']; ?></span></strong></td>
 </tr>

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

 <?php
  $query_produtos = "SELECT * FROM produtos WHERE id_material='".$row_categ_list['id_material']."' ORDER BY ordem ASC";
  $produtos = mysql_query($query_produtos, $futura) or die(mysql_error());
  $row_produtos = mysql_fetch_assoc($produtos);
  $totalRows_produtos = mysql_num_rows($produtos);

  do
  {
   $query_verimg = "SELECT * FROM produtos_img WHERE id_produto='".$row_produtos['id_produto']."' ORDER BY default_ DESC";
   $verimg = mysql_query($query_verimg, $futura) or die(mysql_error());
   $row_verimg = mysql_fetch_assoc($verimg);
  ?>
   <tr>
	<td height="10px">
	</td>
   </tr>

   <tr>
	<td width="160" height="95" valign="top">
	 <a href="ver_produto.php?id_produto=<?php echo $row_produtos['id_produto']; ?>&id_categoria=<?php echo $row_produtos['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>
   </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_produtos = mysql_fetch_assoc($produtos));
 ?>
<?PHP
 } while ($row_categ_list = mysql_fetch_assoc($categ_list));
?>
  </table>
 </td>
<?PHP
} while ($row_produtos = mysql_fetch_assoc($produtos));
?>
<!---------------------------------------end/IMAGEM-GRANDE--------------------------------------->
<!--------------------------------------begin/TABELA-NORMAL-------------------------------------->
<?PHP
;}
else
{
?>
<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_categ_list['id_material']; ?>"></a>  <strong>PRODUTOS :: <span class="texto2"><?php echo $row_categ_list['material']; ?></span></strong></td>
</tr>

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

<?php
 $query_produtos = "SELECT * FROM produtos WHERE id_material='".$row_categ_list['id_material']."' ORDER BY ordem ASC";
 $produtos = mysql_query($query_produtos, $futura) or die(mysql_error());
 $row_produtos = mysql_fetch_assoc($produtos);
 $totalRows_produtos = mysql_num_rows($produtos);

 do{
  $query_verimg = "SELECT * FROM produtos_img WHERE id_produto='".$row_produtos['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_produtos['id_produto']; ?>&id_categoria=<?php echo $row_produtos['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_produtos['referencia']; ?><br />
	  <strong>DESCRIÇÃO:</strong> <?php echo $row_produtos['nome']; ?>
	  <br/>
	  <br/>
	  <br/>
	  <div id="a_img">
	   <a href="ver_produto.php?id_produto=<?php echo $row_produtos['id_produto']; ?>&id_categoria=<?php echo $row_produtos['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_produtos = mysql_fetch_assoc($produtos));
 ?>

<tr>
 <td width="160" height="30"></td>
 <td height="10" align="right"><a href="#topo" style="text-decoration:none;"><img src="imagens/arrow.gif" border="0" align="absmiddle" /> Topo da página</a> </td>
</tr>
 <?PHP
  } while ($row_categ_list = mysql_fetch_assoc($categ_list));
 ?>
</table>
</td>
<?PHP
;}
?>
<!---------------------------------------end/TABELA-NORMAL--------------------------------------->

Eu acrescentei o var_dump() para testar e quando escrevo var_dump ($prods['img_grande']=='Sim') ele retorna boolean False.

Alguém me pode ajudar, sff?

Obrigado,

PF2G

Posted (edited)
$sql_produtos = "SELECT * FROM produtos WHERE img_grande = 'Sim'";
$prods = mysql_query($sql_produtos, $futura) or die(mysql_error());
$row_prods = mysql_fetch_assoc($prods);
$totalRows_prods = mysql_num_rows($prods);
var_dump($prods['img_grande']=='Sim');exit;

??

nao querias fazer :

var_dump($row_prods['img_grande']=='Sim');exit;
Edited by HappyHippyHippo
IRC : sim, é algo que ainda existe >> #p@p
Posted (edited)

$sql_produtos = "SELECT * FROM produtos WHERE img_grande = 'Sim'";
$prods = mysql_query($sql_produtos, $futura) or die(mysql_error());
$row_prods = mysql_fetch_assoc($prods);
$totalRows_prods = mysql_num_rows($prods);
var_dump($prods['img_grande']=='Sim');exit;

??

nao querias fazer :

var_dump($row_prods['img_grande']=='Sim');exit;

Assim:

if ($row_prods['img_grande']=='Sim')
{

põe-me todos os produtos com imagem grande e eu só quero os produtos que tenham img_grande='Sim' os que não tiverem nada dá-me a tabela normal:

imagem pequena, descrição e referencia...

Edited by PF2G
Posted

põe-me todos os produtos com imagem grande e eu só quero os produtos que tenham img_grande='Sim' os que não tiverem nada dá-me a tabela normal:

imagem pequena, descrição e referencia...

não .. esse português está errado, deveria ser:

põe-me os produtos com imagem grande ...

olha bem para o teu SQL :

$sql_produtos = "SELECT * FROM produtos WHERE img_grande = 'Sim'";

só te retorna os elementos em que no campo img_grande contem o valor exacto "Sim".

todos os outros que nesse campo esteva outra coisa qualquer, não iram ser listados

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

só te retorna os elementos em que no campo img_grande contem o valor exacto "Sim".

todos os outros que nesse campo esteva outra coisa qualquer, não iram ser listados

Não esse português está errado não iram, é irão..

Entao tenho de tirar o WHERE, é?

Posted

Alguém me pode ajudar, sff?

Eu ja tentei varios WHERE 's e assume sempre que todos os produtos têm img_grande='Sim':

$query_categ_list = "SELECT * FROM materiais ORDER BY ordem ASC";
$categ_list = mysql_query($query_categ_list, $futura) or die(mysql_error());
$row_categ_list = mysql_fetch_assoc($categ_list);
$totalRows_categ_list = mysql_num_rows($categ_list);
<!--------------------------------------begin/IMAGEM-GRANDE-------------------------------------->
<?PHP
$sql_produtos = "SELECT id_produto, img_grande FROM produtos WHERE id_produto='".$row_categ_list['id_material']."'";
$prods = mysql_query($sql_produtos, $futura) or die(mysql_error());
$row_prods = mysql_fetch_assoc($prods);
$totalRows_prods = mysql_num_rows($prods);
//var_dump($row_prods['img_grande']=='Sim'); exit;
if ($row_prods['img_grande']=='Sim')
{
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_categ_list['id_material']; ?>"></a>  <strong>PRODUTOS :: <span class="texto2"><?php echo $row_categ_list['material']; ?></span></strong></td>
 </tr>

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

 <?php
  $query_produtos = "SELECT * FROM produtos WHERE id_material='".$row_categ_list['id_material']."' ORDER BY ordem ASC";
  $produtos = mysql_query($query_produtos, $futura) or die(mysql_error());
  $row_produtos = mysql_fetch_assoc($produtos);
  $totalRows_produtos = mysql_num_rows($produtos);

  do
  {
   $query_verimg = "SELECT * FROM produtos_img WHERE id_produto='".$row_produtos['id_produto']."' ORDER BY default_ DESC";
   $verimg = mysql_query($query_verimg, $futura) or die(mysql_error());
   $row_verimg = mysql_fetch_assoc($verimg);
  ?>
   <tr>
	<td height="10px">
	</td>
   </tr>

   <tr>
	<td width="160" height="95" valign="top">
	 <a href="ver_produto.php?id_produto=<?php echo $row_produtos['id_produto']; ?>&id_categoria=<?php echo $row_produtos['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=190px&h=154px&zc=1&q=100" width="190" height="154" style="border:1px solid #cccccc;" /><?php } else { ?><img src="imagens/futura.jpg" width="190" height="154" style="border:1px solid #cccccc;" /><?php } ?></a>
	</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_produtos = mysql_fetch_assoc($produtos));
 ?>

  <tr>
   <td width="160" height="30"></td>
	<td height="10" align="right"><a href="#topo" style="text-decoration:none;"><img src="imagens/arrow.gif" border="0" align="absmiddle" /> Topo da página</a> </td>
  </tr>

<?PHP
 } while ($row_categ_list = mysql_fetch_assoc($categ_list));
?>
  </table>
 </td>
<?PHP
} while ($row_produtos = mysql_fetch_assoc($produtos));
?>
<!---------------------------------------end/IMAGEM-GRANDE--------------------------------------->
<!--------------------------------------begin/TABELA-NORMAL-------------------------------------->
<?PHP
;}
else
{
?>
<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_categ_list['id_material']; ?>"></a>  <strong>PRODUTOS :: <span class="texto2"><?php echo $row_categ_list['material']; ?></span></strong></td>
</tr>

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

<?php
 $query_produtos = "SELECT * FROM produtos WHERE id_material='".$row_categ_list['id_material']."' ORDER BY ordem ASC";
 $produtos = mysql_query($query_produtos, $futura) or die(mysql_error());
 $row_produtos = mysql_fetch_assoc($produtos);
 $totalRows_produtos = mysql_num_rows($produtos);

 do{
  $query_verimg = "SELECT * FROM produtos_img WHERE id_produto='".$row_produtos['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_produtos['id_produto']; ?>&id_categoria=<?php echo $row_produtos['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_produtos['referencia']; ?><br />
	  <strong>DESCRIÇÃO:</strong> <?php echo $row_produtos['nome']; ?>
	  <br/>
	  <br/>
	  <br/>
	  <div id="a_img">
	   <a href="ver_produto.php?id_produto=<?php echo $row_produtos['id_produto']; ?>&id_categoria=<?php echo $row_produtos['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_produtos = mysql_fetch_assoc($produtos));
 ?>

<tr>
 <td width="160" height="30"></td>
 <td height="10" align="right"><a href="#topo" style="text-decoration:none;"><img src="imagens/arrow.gif" border="0" align="absmiddle" /> Topo da p⨩na</a> </td>
</tr>
 <?PHP
  } while ($row_categ_list = 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
;}
?>
<!---------------------------------------end/TABELA-NORMAL--------------------------------------->

Por favor ajudem-me.

Posted

verifica os teus ciclos while ... ja te disse para deixares os do {} while()

enquanto não fizeres isso, nem me vou preocupar mais

razões :

- o código estoira imediatamente caso não exista categorias e/ou não existam produtos dessa categoria

- existe um erro muito grave relacionado ao teu encadeamento de ciclos

- já te foi dito e fizeste ouvidos moucos

- o teu if inicial não tem sentido pois só queres trocar a imagem e não a informação da tabela que aparece

..

IRC : sim, é algo que ainda existe >> #p@p
Posted (edited)

Problema Resolvido.

Como é que faço para fazer Topico Resolvido?

Infelizmente estamos com problemas na atribuição de direitos. Só tem tem direitos de moderação no forum é que, atualmente, consegue.

Edited by brunoais

"[Os jovens da actual geração]não lêem porque não envolve um telecomando que dê para mirar e atirar, não falam porque a trapalhice é rainha e o calão é rei" autor: thoga31

Life is a genetically transmitted disease, induced by sex, with death rate of 100%.

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.