• Howdy! Welcome to our community of more than 130.000 members devoted to web hosting. This is a great place to get special offers from web hosts and post your own requests or ads. To start posting sign up here. Cheers! /Peo, FreeWebSpace.net
managed wordpress hosting

table probs...

OriginXT

New Member
Well, I'm creating my own gallery script.

I'm wondering how to create "X" columns.

For example,
<tr>

for each X number, how to create <td>the image</td>

(for each number up to X)

Thanks in ADV!


Oh yeah, how to resize images/create thumbnails of images?
 
hm

I'm not positive what you asked but here:

Code:
<table>
 <tr>
 <td>Hi</td>
 <td>There</td>
 </tr>
</table>
Would make two columns.

Code:
<table>
 <tr>
 <td>Hi</td>
 </tr>
 <tr>
 <td>There</td>
  </tr>
</table>

Would make two rows.

Code:
<img src="Image URL" width="100" height="100">

Would resize image to 100x100.
 
Soorry yo misunderstand me

I mean with a foreach, for, or while loop to create tds.

USING PHP!

And how to resize using PHP, not HTML!
 
something like:

PHP:
$count = 0;
$num_col = 4;
$echo = "<table><tr>";

while($count < $num_col) {

$echo .= "<td>column</td";
$count = $count +1;

if($count == $num_col) {
$echo .= "</tr></table>";

echo $echo;

}
}

whiped that up real quick but something like that should do the trick.
 
Maybe the source code for my script should make it easier to understand...

<html>
<head>
<title><?php
if(!empty($title)){print "$title";}else{print "Image Gallery";}?></title>
</head>
<body>
<?php
$small="small";
$full="large";
// < the folders >
if(empty($dir)){$dir=".";}
if(empty($smalldir)){$smalldir="$dir";}
if(empty($base)){$base="";}
if(empty($par)){$par=" width=100 height=100";}
// < start variables section >
$filetype=array('gif','GIF','bmp','BMP','jpg','jpe','JPG','JPE','png','PNG','JPEG','jpeg');//the accepted formats
$table="table align=center width=600 cellspacing=1 cellpadding=5 border=0 bgcolor=#FFFFFF";
$td="td align=center bgcolor=#222244";
$font="font face=Times";//the font
$clickme="Click on an image for a closer look";//the click message
$previous=" previous image ";//next, previous & back to overview text
$next=" next image ";

// < end variables section >


// << THE SCRIPT >>

if (empty($size)){
$size="$small";
}
$limit=count($filetype);
if ($handle=opendir("$base$dir")){
while (false !==($file=readdir($handle))){
for($i=0;$i<$limit;$i++){
if (strpos($file, $filetype[$i])==false){}else{
$filelist[]="$file";
}}}
closedir($handle);
}
if ($handle2=opendir("$base$smalldir")){
while (false !==($file2=readdir($handle2))){
for($i=0;$i<$limit;$i++){
if (strpos($file2, $filetype[$i])==false){}else{
$smallimage[]="$file2";
}}}
closedir($handle2);
}
sort($filelist);
reset($filelist);
sort($smallimage);
reset($smallimage);
$count=count($filelist);
$count=($count - "1");
print "<$table>";
if(!empty($title)){print "<tr><$td><p class=topic>$title</p></td></tr>";}
print "<tr><$td>\r\n";

if ($size=="$small"){
while (list($arr)=each($filelist)){
print "<a href=\"$PHP_SELF?id=$id&base=$base&size=$full&image=$arr&dir=$dir&smalldir=$smalldir&title=$title&par=$par\"><img$par border=0 src=$base$smalldir/$smallimage[$arr]></a>\r\n";
}}else {
print "<img src=$base$dir/$filelist[$image]>";
}
print "</td></tr><tr><$td>";

if ($size=="$small"){
print "<$font>$clickme</font>";
}
if ($size=="$full"){

if ($image=="0"){
$prevnr="$count";
$nextnr="1";
}
elseif ($image==$count){
$prevnr=($image - "1");
$nextnr="0";
}
else{
$prevnr=($image - "1");
$nextnr=($image + "1");
}
print "<$font><a href=\"$PHP_SELF?id=$id&size=$full&image=$prevnr&dir=$dir&smalldir=$smalldir&title=$title&par=$par\">$previous</a>&nbsp";
print "<a href=\"$PHP_SELF?id=$id&size=$full&image=$nextnr&dir=$dir&smalldir=$smalldir&title=$title&par=$par\">$next</a><br><a href=\"$PHP_SELF?id=$id&dir=$dir&par=$par&smalldir=$smalldir&base=$base&title=$title\">Return to thumbnail view</a></font>";
}
print "</tr></td></table>";
?><p align=center><a href="#TOP">TOP</a></p>
</body>
</html>
 
Back
Top