ThA_FiLeR Posted July 5, 2003 Posted July 5, 2003 Right, just got done creating my script that allows me and someone else to add a portfolio item to site, it allows u to upload pic from hd, then creates thumbnail also for it and makes thumbnail link to original image with a title above it.. it shows fine and everything, only problem is that I would like it to show 4 items across (columns) and then start a new row underneath, and so on.. now it keeps on making new columns or rows for it, and keeps going I can make it go across or down but it keeps going.. so I need it to show just 4 across then start new line, heres my code...<html><head><title>Portfolio site</title></head><body><?php // Connect to the database $db = mysql_connect("localhost","****","****"); mysql_select_db ("****"); // Request info from Portfolio table$result = mysql_query("SELECT * FROM portfolio"); // Start showing resultsecho "<table border = '0' width = '780' align='center'><tr>"; while ($rows = mysql_fetch_row($result)) // keeps looping till all items from DB are shown{ echo "<td>$rows[1]<BR><a href='$rows[2]'><img src=$rows[3]></a></td>"; } echo "</tr></table>"; ?> </body></html>**** = hidden rows[1] = title rows[2] = original imagerows[3] = thumbnail imageScript in action: http://www.toe-art.com/QualityCreations/portfolio.php-the TF avater pic looks not right since it got resized b/c it was too small and it then got resized bigger instead..Thanks for any help/suggestion..
sedative Posted July 6, 2003 Posted July 6, 2003 Here's the index.php that a friend made for me for my images on ileet.net. Maybe this will help.<?phpinclude('http://ileet.net/source/header.php');// CONFIGURE THIS$dir_name = ""; $thumb_dir_name = "thumbs/"; // AND THAT ONLY =)$dir = opendir($thumb_dir_name); if (!$pg) { $pg = 1; }$e = $pg * 15;$pg--; $s = $pg * 15;$i = 0;$r = 0;echo "<table cellspacing=1 cellpadding=5 align=center>";while ($file_name = readdir($dir)){ // if (ereg ("^[]+\.(jpg|gif|jpeg|png)$", $file_name)) { if (($file_name != "..") && ($file_name != ".") && ($file_name != "_vti_cnf")) { $fName = "$file_name"; if (($i >= $s) && ($i < $e)) { if ($r == 5) { $r = 0; echo "</tr>"; } if (!$r) { echo "<tr>"; } $file = "$dir_name$fName"; $size = @GetImageSize($file); $filesize = @filesize($file); $filesize = $filesize / 1024; $filesize = @round($filesize,0); $h = $size[1]; $w = $size[0]; if (($w) && ($h)) { $size = "$w x $h, $filesize<b></b>kb"; } elseif ((!$w) || (!$h)) { $size = "n/a, $filesize<b></b>kb"; } echo "<td> <a href=\"$file\"><img src=\"$thumb_dir_name$fName\" alt=\"\" border=0></a></td>"; $r++; } $i++; } } if ($r != 5) echo "</tr>";echo "</table>";echo "<div align=\"center\">";$total = $i; // Number of images in directory$i = 1; // iiiiiiih!$img_per_page = 15; // Number of images per page. Change this any day =)$cur_img = 1;$total_pages = 1;while ($i <= $total) { if ($cur_img == $img_per_page) { if ($_GET["pg"] != $total_pages) { echo "<a href=\"$PHP_SELF?pg=$total_pages\">$total_pages</a> "; } else { echo "$total_pages "; } if ($i < $total) { $total_pages++; } $cur_img = 0; } elseif ($i == $total) { $isdone = $total_pages * $img_per_page; if ($isdone > $total) { // BEEP! More pix! if ($_GET["pg"] != $total_pages) { echo "<a href=\"$PHP_SELF?pg=$total_pages\">$total_pages</a> "; } else { echo "$total_pages "; } } } $cur_img++; $i++;}/**$pgs = $i / 15;$pgs = round($pgs,0);$c = $i % 15;if ($c != 0) $pgs++;$i = 1; $p = $pg + 1;echo "<div align=\"center\">";while ($i < $pgs) { if ($p == $i) echo "$i "; else echo "<a href=\"$PHP_SELF?pg=$i\">$i</a> ";$i++;}**/echo "</div>";closedir($dir); include('http://ileet.net/source/footer.php');?>
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now