NamePros
Welcome, Guest! Ready to make a name for yourself in the domain business? We welcome both the hobbyist and professional domainer to join the discussion as part of the NamePros community.

Click here to create your profile to start earning reputation for posting, and trader ratings for buying & selling in our free e-marketplace. Build your trader rating with each successful sale. Our system has tracked over 100,000 sales and counting!
FAQ & TOS Register Search Today's Posts Mark Forums Read

Go Back   NamePros.com > Website Development Discussion Forums > Programming
Reload this Page need some help.. trying to display images from a folder.

Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics.

Advanced Search


Closed Thread
 
LinkBack Thread Tools
Old 11-06-2007, 01:08 PM THREAD STARTER               #1 (permalink)
dot
NamePros Regular
Join Date: Jul 2003
Posts: 411
dot will become famous soon enoughdot will become famous soon enough
 



need some help.. trying to display images from a folder.


hey

i have a folder with the following files

1002.jpg
1002_b.jpg
1003.jpg
1003_b.jpg
1004.jpg
1004_b.jpg

I'd like to display all the "non _b" images on a page. They're thumbnails. Then I'd like them to be linked to the _b version.

There has to be an easy way to do this in PHP.. Can you point me in the right direction?

Thanks..
__________________
.
dot is offline  
Old 11-06-2007, 02:44 PM   #2 (permalink)
NamePros Regular
Join Date: Apr 2006
Posts: 254
Wuoshi is a jewel in the roughWuoshi is a jewel in the roughWuoshi is a jewel in the rough
 



Depends on how you want to present the images, but this is one way to do it:

<a href="1002_b.jpg"><img src="1002.jpg" /></a>
Wuoshi is offline  
Old 11-06-2007, 03:01 PM   #3 (permalink)
Danltn.com
 
Daniel's Avatar
Join Date: May 2007
Location: Danltn.com / Nottingham, UK
Posts: 1,201
Daniel has a reputation beyond reputeDaniel has a reputation beyond reputeDaniel has a reputation beyond reputeDaniel has a reputation beyond reputeDaniel has a reputation beyond reputeDaniel has a reputation beyond reputeDaniel has a reputation beyond reputeDaniel has a reputation beyond reputeDaniel has a reputation beyond reputeDaniel has a reputation beyond reputeDaniel has a reputation beyond repute
 


Ethan Allen Fund Ethan Allen Fund
Originally Posted by Wuoshi
Depends on how you want to present the images, but this is one way to do it:

<a href="1002_b.jpg"><img src="1002.jpg" /></a>
Don't think that's quite what he meant. There's tons of ways of doing it though.
????: NamePros.com http://www.namepros.com/programming/392893-need-some-help-trying-display-images.html

PHP Code:
<?php

$absinternal 
"/home/danltn/www/images/"// Include ending slashes
????: NamePros.com http://www.namepros.com/showthread.php?t=392893
$absexternal "http://danltn.com/images/";

if (
$handle opendir($absinternal))
{

    while (
true == ($file readdir($handle)))
    {
        if (
substr($file, -62) == "_b")
        {
            
$img str_replace("_b"""$file); // Tons of ways of doing this, this is just one way.
            
echo "<a href='$absexternal$img'><img src='$absexternal$file' border='0'></a><br />"// Output
        
}
    }

    
closedir($handle);
}
?>
Daniel is offline  
Old 11-06-2007, 03:11 PM   #4 (permalink)
NamePros Regular
Join Date: Apr 2006
Posts: 254
Wuoshi is a jewel in the roughWuoshi is a jewel in the roughWuoshi is a jewel in the rough
 



That would make it more dynamic and easier if you intend to add more pictures later. I just didn't see the need to make it harder than it had to be when there were so few images.
Wuoshi is offline  
Closed Thread


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools


Liquid Web Smart Servers  
All times are GMT -7. The time now is 09:11 AM.

Managed Web Hosting by Liquid Web
Domain name forum recommended by Domaining.com Powered by: vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.6.0 Ad Management plugin by RedTyger