Very basic gallery

Support, Snippets & Projects

Moderators: Moderator, Global Moderator

Post Reply
Tibs
Global Moderator
Global Moderator
Posts: 0
Joined: Tue Jun 15, 2004 4:59 pm

Very basic gallery

Post by Tibs »

Ok I coded this gallery for my website a while ago, I did evertyhing myself with some help from Vercz I think. Anyway I would like to get the images to show in 2 Rows instead of 1.

Here\'s the code, if you can you may improve it but then I would like to know what you change and why <img src=\'http://www.killanet.net/forum3/public/s ... >/blum.gif\' class=\'bbc_emoticon\' alt=\':P\' /> so I learn something from it.

Code: Select all

<?php
if &#40;$handle = opendir&#40;\'Portfolio\'&#41;&#41; {
	while &#40;false !== &#40;$file = readdir&#40;$handle&#41;&#41;&#41; {
if &#40;$file != \'.\' && $file != \'..\' && preg_match&#40;"/prev/",$file&#41;&#41; {
$open = str_replace&#40;"&#40;prev&#41;","",$file&#41;;
$show = str_replace&#40;".jpg","",$open&#41;;
echo " <b> $show </b><br><a href=&#092;"Portfolio/{$open}&#092;" target=&#092;"&#092;_blank&#092;"><img src=&#092;"Portfolio/{$file}&#092;" alt=&#092;"&#092;" border=&#092;"0&#092;" /></a><br><br>";
	}
}
	closedir&#40;$handle&#41;;
}
?>
Thanks In advance.
...
ner0
Newbie
Newbie
Posts: 0
Joined: Sat May 22, 2004 4:45 pm

Very basic gallery

Post by ner0 »

Code: Select all

<?php

	if &#40;$handle = opendir&#40;\'Portfolio\'&#41;&#41; {
				$numonrow = 0;
		while &#40;false !== &#40;$file = readdir&#40;$handle&#41;&#41;&#41; {
			if &#40;$file != \'.\' && $file != \'..\' && preg_match&#40;"/prev/",$file&#41;&#41; {

				//edit, check if we\'ve already output 2 images on this row. if so, start new row.
				if &#40;$numonrow == 2&#41; {
					echo "<br /><br />";
										$numonrow = 0;
				}

				$numonrow++;

				$open = str_replace&#40;"&#40;prev&#41;","",$file&#41;;
				$show = str_replace&#40;".jpg","",$open&#41;;
				echo " <b> $show </b><br><a href=&#092;"Portfolio/{$open}&#092;" target=&#092;"&#092;_blank&#092;"><img src=&#092;"Portfolio/{$file}&#092;" alt=&#092;"&#092;" border=&#092;"0&#092;" /></a>";
			}
		}
		closedir&#40;$handle&#41;;
	}
?>
try that, not sure if it\'s what you\'re going for, basically only added the 3 lines under the comment, also removed the default

after the image so it -should- put 2 per line, quite a while since i coded <img src=\'http://www.killanet.net/forum3/public/s ... #>/cry.gif\' class=\'bbc_emoticon\' alt=\':(\' />
Last edited by ner0 on Sat Nov 26, 2005 5:48 pm, edited 1 time in total.
[color=\"green\"]'class KPIM::ProcessManager' only defines private constructors and has no friends[/color] <- :( poor class



[18:09:00] * ~Moppy stews ner0 erotically 1 times.
Tibs
Global Moderator
Global Moderator
Posts: 0
Joined: Tue Jun 15, 2004 4:59 pm

Very basic gallery

Post by Tibs »

That didn\'t work nero <img src=\'http://www.killanet.net/forum3/public/s ... >/blum.gif\' class=\'bbc_emoticon\' alt=\':P\' /> anyway thanks for the effort.
...
ner0
Newbie
Newbie
Posts: 0
Joined: Sat May 22, 2004 4:45 pm

Very basic gallery

Post by ner0 »

what exactly went wrong, I didn\'t bet on it being perfect first time but a little more debug info would help?
[color=\"green\"]'class KPIM::ProcessManager' only defines private constructors and has no friends[/color] <- :( poor class



[18:09:00] * ~Moppy stews ner0 erotically 1 times.
Tibs
Global Moderator
Global Moderator
Posts: 0
Joined: Tue Jun 15, 2004 4:59 pm

Very basic gallery

Post by Tibs »

Hmm sorry \'bout that ner0, I\'m a bit sick and get annoyed quite fast then.

Anyway what went wrong is it placed the pics under each other but in steps.

Hmm way to hard to explain, just check

http://tibs.killanet.net/Portfolio.html
...
ner0
Newbie
Newbie
Posts: 0
Joined: Sat May 22, 2004 4:45 pm

Very basic gallery

Post by ner0 »

no worries, I didn\'t mean my last msg to sound short.. if it did then my bad, I just wanted to help dat all <img src=\'http://www.killanet.net/forum3/public/s ... >/blum.gif\' class=\'bbc_emoticon\' alt=\':P\' />

looks like you got it sorted <img src=\'http://www.killanet.net/forum3/public/s ... >/good.gif\' class=\'bbc_emoticon\' alt=\'(Y)\' />
[color=\"green\"]'class KPIM::ProcessManager' only defines private constructors and has no friends[/color] <- :( poor class



[18:09:00] * ~Moppy stews ner0 erotically 1 times.
Brock
Newbie
Newbie
Posts: 0
Joined: Thu Jun 17, 2004 12:37 am

Very basic gallery

Post by Brock »

hmm...

Just what I was looking for...Tibs reckon I could get a copy of your source?
Post Reply

Return to “PHP &amp; MySQL”