
06-26-09, 02:13 AM
|
 |
Community Liaison
|
|
Join Date: Dec 2006
Location: Tacoma, Washington USA
Posts: 3,454
Thanks: 0
Thanked 140 Times in 137 Posts
|
|
I didn't have time to edit my post.
I used float:left; for the image container so I wouldn't have to specify a width.
And I added some margins to the image container that will position the images more to the center of the page, at least on my computer.
I put the margins in so you can see how to move it around.
PHP Code:
<?php $user = "ishmell"; // $user can be loaded through $_POST or $_GET or even a $_SESSION variable. // $limit = 2; // Set $limit to the maximum number of pictures you want displayed. //
$host = "localhost"; // Enter mysql host address here. // $username = "root"; // Enter mysql username here. // $password = ""; // Enter mysql password here. // $db = "test"; // Enter mysql database name here. // $table = "user"; // Enter mysql table name here. //
$images = array("img1.jpg","img2.jpg","img3.jpg","img4.jpg","img5.jpg","img6.jpg","img7.jpg","img8.jpg","img9.jpg","img10.jpg","img11.jpg","img12.jpg","img13.jpg","img14.jpg","img15.jpg","img16.jpg","img17.jpg","img18.jpg","img19.jpg","img20.jpg","img21.jpg","img22.jpg","img23.jpg","img24.jpg","img25.jpg","img26.jpg","img27.jpg","img28.jpg","img29.jpg","img30.jpg","img31.jpg","img32.jpg"); $count = 0;
mysql_connect($host,$username,$password) or die(mysql_error()); mysql_select_db($db) or die(mysql_error());
$sql = "SELECT * FROM $table WHERE username = '$user' LIMIT $limit"; $results = mysql_query($sql) or die(mysql_error()); if($results) { while($row = mysql_fetch_assoc($results)) { $images[$count] = $row["picture"]; $count++; } } ?> <html> <head> <title></title> <style> body{background:#000;} .img_container { float:left; margin-left:17%; margin-top:8%; padding:4px; border:4px solid #00f; background:#aaf; } .img_css { width:100px; height:100px; margin:4px; } </style> </head> <body> <div class="img_container"> <?php $count = 1; $images_per_row = 8; for($i=0;$i<count($images);$i++) { echo "<img class='img_css' src='".$images[$i]."' alt='".$images[$i]."' />"; $count++; if($count > $images_per_row){echo "<br />";$count=1;} } ?> </div> </body> </html>
__________________
Jerry Broughton
Last edited by job0107; 06-26-09 at 02:26 AM.
|