[advanced search]
 

Go Back   NamePros.com > Discussion > Web Design & Development > Programming

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


Closed Thread
 
LinkBack Thread Tools
Old 11-06-2007, 12:08 PM   #1 (permalink)
dot
NamePros Regular
 
Join Date: Jul 2003
Posts: 412
202.00 NP$ (Donate)

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, 01:44 PM   #2 (permalink)
NamePros Member
 
Join Date: Apr 2006
Posts: 150
0.00 NP$ (Donate)

Wuoshi is on a distinguished road


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>
__________________
Organic beauty www.onlyorganic.no
Wuoshi is offline  
Old 11-06-2007, 02:01 PM   #3 (permalink)
Danltn.com
 
Daniel's Avatar
 
Join Date: May 2007
Location: Danltn.com / Nottingham, UK
Posts: 1,201
13.51 NP$ (Donate)

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
Quote:
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.

PHP Code:
<?php

$absinternal
= "/home/danltn/www/images/"; // Include ending slashes
$absexternal = "http://danltn.com/images/";

if (
$handle = opendir($absinternal))
{

    while (
true == ($file = readdir($handle)))
    {
        if (
substr($file, -6, 2) == "_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, 02:11 PM   #4 (permalink)
NamePros Member
 
Join Date: Apr 2006
Posts: 150
0.00 NP$ (Donate)

Wuoshi is on a distinguished road


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.
__________________
Organic beauty www.onlyorganic.no
Wuoshi is offline  
Closed Thread


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

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Site Sponsors
Advertise your business at NamePros

All times are GMT -7. The time now is 12:06 PM.


Powered by: vBulletin® Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0
Template-Modifications by TMS
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85