Guest User

index.php

a guest
Jan 12th, 2011
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.24 KB | None | 0 0
  1. <?php
  2. $conecta = mysql_connect("localhost","root","") or die (mysql_error());
  3. $db = mysql_select_db("va") or die (mysql_error());
  4. ?>
  5. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  6. <html xmlns="http://www.w3.org/1999/xhtml">
  7. <head>
  8. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  9. <title>vitrine de produtos</title>
  10. <style type="text/css">
  11.     #conteudo{
  12.         width:900px;
  13.         background:#333;
  14.         padding:10px;
  15.         margin:50px auto;
  16.         }
  17. </style>
  18. </head>
  19.  
  20. <body>
  21. <div id="conteudo">
  22. <table cellpadding="8" cellspacing="10" border="0" width="100%">
  23.     <tr>
  24.     <?php
  25.         $loop = 3;
  26.         $select = "SELECT * FROM produtos";
  27.         $qr = mysql_query($select);
  28.         $i = 1;
  29.         while($ln = mysql_fetch_array($qr)){
  30.             if($i < $loop){
  31.                 echo '
  32.                 <td valign="top" align="center" bgcolor="#f4f4f4">
  33.                 <img src="'.$ln['caminho'].$ln['foto'].'" width="200" alt="" />        
  34.                 </td>
  35.                 ';
  36.             }elseif($i = $loop){
  37.                 echo '
  38.                 <td valign="top" align="center" bgcolor="#f4f4f4">
  39.                 <img src="'.$ln['caminho'].$ln['foto'].'" width="200" alt="" />        
  40.                 </td>
  41.                 </tr>
  42.                 <tr>
  43.                 ';
  44.                 $i = 0;
  45.             }
  46.         $i++;
  47.         }
  48.     ?>
  49.     </tr>
  50. </table>
  51. </div>
  52. </body>
  53. </html>
Advertisement
Add Comment
Please, Sign In to add comment