IMage code
Moderator: General Moderators
IMage code
Hi pro's!
I'm in a bad situation here , i made a website in php , with tables , pics and text.
Now this website is made for an foto studio , and the guy wants to put some images on his site for a preview of his work. But he nows <span style='color:blue' title='I'm naughty, are you naughty?'>smurf</span> about websites so he cant change pics and things.
Now i've heard of a friend that there is a way via the FTP to put a map on it load some pics in it and the pics will be shown on the site... but how do you do that ? ANd can you set them in a table so there is a black border on them ?
PLzzz... Can someone help me ?
THX !
I'm in a bad situation here , i made a website in php , with tables , pics and text.
Now this website is made for an foto studio , and the guy wants to put some images on his site for a preview of his work. But he nows <span style='color:blue' title='I'm naughty, are you naughty?'>smurf</span> about websites so he cant change pics and things.
Now i've heard of a friend that there is a way via the FTP to put a map on it load some pics in it and the pics will be shown on the site... but how do you do that ? ANd can you set them in a table so there is a black border on them ?
PLzzz... Can someone help me ?
THX !
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
Code: Select all
<?php
$dir = "what/ever/you/want/";
if ($handle = opendir($dir)) {
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != "..") {
echo "<img src='$dir/$file' border='1'>";
}
}
closedir($handle);
}
?>- mudkicker
- Forum Contributor
- Posts: 479
- Joined: Wed Jul 09, 2003 6:11 pm
- Location: Istanbul, TR
- Contact:
Code: Select all
<?
echo "<a href="$dir/$file"><img src='$dir/$file' border='1'></a>";
?>...but displaying thumbnails, that themselves link to the BIG images would work... Depends on whats wanted.vigge89 wrote:the code Phenom posted echos out an image-tag for each file in the directory, not only images. also, i think you want a thumbnail-system? Phenoms code just shows the images in whole, so if you have images in bigger resolutions, the page would look ugly and take long time to load.
Combine phenoms code with mudkickers...
Code: Select all
<?php
$dir = "/images/thumbs/"; // thumbs (duh)
$bigdir = "/images/"; // originalsized, using same names as thumbs
if ($handle = opendir($dir)) {
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != "..") {
echo "<a href="$bigdir/$file"><img src="$dir/$file" border="1"></a>";
}
}
closedir($handle);
}
?>
Last edited by JAM on Wed Apr 21, 2004 4:29 pm, edited 1 time in total.
- mudkicker
- Forum Contributor
- Posts: 479
- Joined: Wed Jul 09, 2003 6:11 pm
- Location: Istanbul, TR
- Contact:
Code: Select all
<?
if ($file != "." && $file != "..")
?>Code: Select all
<?
if (!is_dir($file))
?>- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
Code: Select all
<?php
$i=1;
$dir = "/images/thumbs/"; // thumbs (duh)
$bigdir = "/images/"; // originalsized, using same names as thumbs
echo '<table>';
if ($handle = opendir($dir)) {
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != "..") {
$i++;
// opens row and column is remainder is odd else open column
if ($i%2=='1'){ echo '<tr><td>'; }else{ echo '<td>'; }
echo "<a href="$bigdir/$file"><img src="$dir/$file" border="1"></a>";
// closes row and column is remainder is odd else close column
if ($i%2=='1'){ echo '</td></tr>'; }else{ echo '</td>'; }
}
}
echo '</table>';
closedir($handle);
}
?>[Edit: Fixed errors in both mine and this post, my fault. --JAM]