SHARE
TWEET

Untitled

a guest Sep 30th, 2013 35 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. //Conexão com Banco de Dados
  3. require_once "conexao.php";
  4. //Executa o SQL selecionando todos os campos da tabela produtos
  5. $query = mysql_query("SELECT * FROM produtos");
  6. ?>
  7.  
  8. <!doctype html>
  9. <html lang="en">
  10.     <head>
  11.         <meta charset="UTF-8">
  12.         <title>Document</title>
  13.     </head>
  14.     <body>
  15.  
  16.         <?php while ($row = mysql_fetch_assoc($query)) : ?>
  17.             <form action="carrinho.php">
  18.                 <img src="image/<?php echo $row['imagem'] ?>" />
  19.                 <h2><?php echo $row['nome']; ?></h2>
  20.                 <p>Preço : R$<?php echo number_format($row['preco'], 2, ',', '.') ?></p>
  21.                
  22.                 <!-- ID do Produto pra adicionar no carrinho-->
  23.                 <input type="hidden" name="id" value="<?php echo $row['id'] ?>" />
  24.                 <button type="submit">Adicionar ao Carrinho</button>
  25.             </form>
  26.         <?php endwhile; ?>
  27.  
  28.     </body>
  29. </html>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top