Images in folders

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • phatnugs420@comcast.net

    Images in folders

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

  • Aidan

    #2
    Re: Images in folders

    You need a HTML tutorial... you don't need PHP to do any of that..


    <phatnugs420@co mcast.net> wrote in message
    news:BD57ED33.7 AA5%phatnugs420 @comcast.net...[color=blue]
    > Hi all I'm a newbie and I need a good starting off point. Basically is[/color]
    there[color=blue]
    > 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.[/color]
    Hope[color=blue]
    > this makes sense. Thanks in advance for the help.
    >
    > Mikey p...
    >[/color]


    Comment

    • Nik Coughin

      #3
      Re: Images in folders

      phatnugs420@com cast.net wrote:[color=blue]
      > 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...[/color]

      function fileListToStrin gs( $aPath )
      {
      $i = 0;
      $files = array();
      clearstatcache( );
      if( $handle = opendir( $aPath ) )
      {
      while( false !== ( $file = readdir( $handle ) ) )
      {
      if( $file != "." && $file != ".." )
      {
      $files[ ++$i ] = $file;
      }
      }
      closedir($handl e);
      }
      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 = fileListToStrin gs( "/images" );

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


      Comment

      • Nik Coughin

        #4
        Re: Images in folders

        Nik Coughin wrote:[color=blue]
        >
        > $aFiles = fileListToStrin gs( "/images" );
        >
        > foreach( $aFiles as $aFile )
        > {
        > echo "<img src=\"/images/$aFile\" alt=\"some alt text\">';
        > }[/color]

        In case your newsreader mangles that code:




        Comment

        • Mikey P

          #5
          Re: Images in folders

          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=nash ville&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" <nospam.aidan@l inknet.com.au> wrote in message news:<newscache $78493i$jrb$1@t itan.linknet.co m.au>...[color=blue]
          > You need a HTML tutorial... you don't need PHP to do any of that..
          >
          >
          > <phatnugs420@co mcast.net> wrote in message
          > news:BD57ED33.7 AA5%phatnugs420 @comcast.net...[color=green]
          > > Hi all I'm a newbie and I need a good starting off point. Basically is[/color]
          > there[color=green]
          > > 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.[/color]
          > Hope[color=green]
          > > this makes sense. Thanks in advance for the help.
          > >
          > > Mikey p...
          > >[/color][/color]

          Comment

          • Ian.H

            #6
            Re: Images in folders

            On 30 Aug 2004 06:25:48 -0700, phatnugs420@com cast.net (Mikey P) wrote:
            [color=blue]
            >Basically i have the city
            >and state information carried over through a link. using
            >.php?city=nash ville&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.. :)[/color]


            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

            Comment

            • Aidan

              #7
              Re: Images in folders

              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" <phatnugs420@co mcast.net> wrote in message
              news:7c63a9c3.0 408300525.46989 aeb@posting.goo gle.com...[color=blue]
              > 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=nashv ille&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" <nospam.aidan@l inknet.com.au> wrote in message[/color]
              news:<newscache $78493i$jrb$1@t itan.linknet.co m.au>...[color=blue][color=green]
              > > You need a HTML tutorial... you don't need PHP to do any of that..
              > >
              > >
              > > <phatnugs420@co mcast.net> wrote in message
              > > news:BD57ED33.7 AA5%phatnugs420 @comcast.net...[color=darkred]
              > > > Hi all I'm a newbie and I need a good starting off point. Basically is[/color]
              > > there[color=darkred]
              > > > 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[/color][/color][/color]
              rows.[color=blue][color=green]
              > > Hope[color=darkred]
              > > > this makes sense. Thanks in advance for the help.
              > > >
              > > > Mikey p...
              > > >[/color][/color][/color]


              Comment

              Working...