By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,408 Members | 1,796 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,408 IT Pros & Developers. It's quick & easy.

Images in folders

P: n/a
Hi all I'm a newbie and I need a good starting off point. Basically is there
a way in php where you can call up all images (jpgs and gifs) within a
directory. Also is there a way to format the images to come up in rows. Hope
this makes sense. Thanks in advance for the help.

Mikey p...

Jul 17 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
You need a HTML tutorial... you don't need PHP to do any of that..
<ph*********@comcast.net> wrote in message
news:BD57ED33.7AA5%ph*********@comcast.net...
Hi all I'm a newbie and I need a good starting off point. Basically is there a way in php where you can call up all images (jpgs and gifs) within a
directory. Also is there a way to format the images to come up in rows. Hope this makes sense. Thanks in advance for the help.

Mikey p...

Jul 17 '05 #2

P: n/a
ph*********@comcast.net wrote:
Hi all I'm a newbie and I need a good starting off point. Basically
is there a way in php where you can call up all images (jpgs and
gifs) within a directory. Also is there a way to format the images to
come up in rows. Hope this makes sense. Thanks in advance for the
help.

Mikey p...


function fileListToStrings( $aPath )
{
$i = 0;
$files = array();
clearstatcache();
if( $handle = opendir( $aPath ) )
{
while( false !== ( $file = readdir( $handle ) ) )
{
if( $file != "." && $file != ".." )
{
$files[ ++$i ] = $file;
}
}
closedir($handle);
}
return $files;
}

That will take a folder ( $aPath ) and return an array of filenames. You
might want to modify it to only put image files into the array, I was using
it to get a complete listing.

Say your images folder is "/images", use it like this:

$aFiles = fileListToStrings( "/images" );

foreach( $aFiles as $aFile )
{
echo "<img src=\"/images/$aFile\" alt=\"some alt text\">';
}
Jul 17 '05 #3

P: n/a
Nik Coughin wrote:

$aFiles = fileListToStrings( "/images" );

foreach( $aFiles as $aFile )
{
echo "<img src=\"/images/$aFile\" alt=\"some alt text\">';
}


In case your newsreader mangles that code:

http://www.nrkn.com/code/gallery.txt
Jul 17 '05 #4

P: n/a
That was so funny i forgot to laugh... Actually i know html pretty
well if memory serves you can't tell it to call up certain information
without using some sort of dynamic code. I was trying to be pretty
simple in my explination because i didn't want someone to hold my
hand, I just needed a starting off point. Basically i have the city
and state information carried over through a link. using
..php?city=nashville&state=TN. I wanted to use this information to make
a call to a certain folder where images reside for nashville TN. they
have a distinct path like ads/nashville/tn. And i wanted to pull all
the images from that folder and put them in rows. I hope this
explination helps avoid any smart @$$ comments.. :)

"Aidan" <no**********@linknet.com.au> wrote in message news:<ne********************@titan.linknet.com.au> ...
You need a HTML tutorial... you don't need PHP to do any of that..
<ph*********@comcast.net> wrote in message
news:BD57ED33.7AA5%ph*********@comcast.net...
Hi all I'm a newbie and I need a good starting off point. Basically is

there
a way in php where you can call up all images (jpgs and gifs) within a
directory. Also is there a way to format the images to come up in rows.

Hope
this makes sense. Thanks in advance for the help.

Mikey p...

Jul 17 '05 #5

P: n/a
On 30 Aug 2004 06:25:48 -0700, ph*********@comcast.net (Mikey P) wrote:
Basically i have the city
and state information carried over through a link. using
.php?city=nashville&state=TN. I wanted to use this information to make
a call to a certain folder where images reside for nashville TN. they
have a distinct path like ads/nashville/tn. And i wanted to pull all
the images from that folder and put them in rows. I hope this
explination helps avoid any smart @$$ comments.. :)

Use opendir() and readdir() to read the contents of the directory. You
can then echo the contents 1 by 1 and format as desired =)

Regards,

Ian
Ian.H
digiServ Network
London, UK
http://digiserv.net/
Jul 17 '05 #6

P: n/a
Sorry Mike, I just assumed that you wanted to display some images that were
in folders... not that you wanted to dynamically display whatever is in a
given directory...

"Mikey P" <ph*********@comcast.net> wrote in message
news:7c**************************@posting.google.c om...
That was so funny i forgot to laugh... Actually i know html pretty
well if memory serves you can't tell it to call up certain information
without using some sort of dynamic code. I was trying to be pretty
simple in my explination because i didn't want someone to hold my
hand, I just needed a starting off point. Basically i have the city
and state information carried over through a link. using
.php?city=nashville&state=TN. I wanted to use this information to make
a call to a certain folder where images reside for nashville TN. they
have a distinct path like ads/nashville/tn. And i wanted to pull all
the images from that folder and put them in rows. I hope this
explination helps avoid any smart @$$ comments.. :)

"Aidan" <no**********@linknet.com.au> wrote in message

news:<ne********************@titan.linknet.com.au> ...
You need a HTML tutorial... you don't need PHP to do any of that..
<ph*********@comcast.net> wrote in message
news:BD57ED33.7AA5%ph*********@comcast.net...
Hi all I'm a newbie and I need a good starting off point. Basically is

there
a way in php where you can call up all images (jpgs and gifs) within a
directory. Also is there a way to format the images to come up in
rows. Hope
this makes sense. Thanks in advance for the help.

Mikey p...

Jul 17 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.