irwan

How to display images using HTML table

Nov 17th, 2011
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.84 KB | None | 0 0
  1. <html xmlns="http://www.w3.org/1999/xhtml">
  2.      <head>
  3.           <title>Dream in code tutorial - List of Images</title>
  4.      </head>
  5.  
  6.      <body>
  7.      
  8.           <div>
  9.  
  10.                <?php     
  11.                     // Grab the data from our upload2 table
  12.                     $sql = "select * from upload2";
  13.                     $result = mysql_query($sql) or die ("Could not access DB: " . mysql_error());
  14.            
  15.             echo "<table border=1>";
  16.                     while ($row = mysql_fetch_assoc($result))
  17.                     {
  18.                          echo "<div class=\"picture\">";
  19.                          echo "<p>";
  20.            
  21.             echo "<tr><td width=200>";
  22.                          // Note that we are building our src string using the filename from the database
  23.              echo $row['name'] . " <br />";
  24.                          echo "<img src=\"images/". $row['name'] . "\" alt=\"\" /> <br /></td></tr>";
  25.                        
  26.                          echo "</p>";
  27.                          echo "</div>";
  28.                     }
  29.             echo"</table>";
  30.                ?>
  31.          
  32.           </div>
  33.      </body>
  34. </html>
  35.  
Advertisement
Add Comment
Please, Sign In to add comment