Jump to content
Joao emilio

Iterar produtos

Recommended Posts

Joao emilio

Galera estou com duvidas ?! Eu quero exibir neste foreach so os produtos cuja categoria seja "Pizzas" mais da erro "unexpected 'where' (T_STRING)"

 

 <?php foreach($products  as $product where $product['categoria'] == 'Pizzas') :?> 	
					
					   <div>
			            <div class="col-sm-6 col-md-4">
							<div class="thumbnail">							    
							    <div class="caption text-center">							      
										
					   			    <img src="imagens/<?php echo $product['imagens']; ?>" alt="<?php echo $product['nome']; ?>">								   				   
								    <h3><?php echo $product['nome']?></h3>
							        <h4>
							  	    R$ <?php echo number_format($product['preco'], 2, ',', '.')?>
							        </h4>
									
							<p><a href="carrinho.php?acao=add&id=<?php echo $product['id']?>" class="btn btn-primary" role="button">Comprar</a> </p>
															
				        </div>
						</div>						
					</div>				
			        </div>
					 
			        <?php endforeach;?>

 

Edited by Joao emilio

Share this post


Link to post
Share on other sites
Joao emilio
9 minutos atrás, HappyHippyHippo disse:

de onde sacaste essa sinaxe do foreach ?

Rsr n sei ..mais deu certo agora ..fiz umas mudanças 

Share this post


Link to post
Share on other sites
Joao emilio
3 minutos atrás, Joao emilio disse:

 

<?php foreach($products as $product):?> 
				        <?php if ($product['categoria'] == 'Pizzas'):?>
						  
			            <div class="col-sm-6 col-md-4">
							<div class="thumbnail">							    
							    <div class="caption text-center">						
								
								    <img src="imagens/<?php echo $product['imagens']; ?>" alt="<?php echo $product['nome']; ?>">								
								   						   
								    <h3><?php echo $product['nome']?></h3>
							        <h4>
							  	    R$ <?php echo number_format($product['preco'], 2, ',', '.')?>
							        </h4>
									
							<p><a href="carrinho.php?acao=add&id=<?php echo $product['id']?>" class="btn btn-primary" role="button">Comprar</a> </p>
							 						  
							</div>
						</div>						
					</div>	
				         
						 <?php endif; ?>
					     <?php endforeach;?>

 

Share this post


Link to post
Share on other sites

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.