D
da_rithm

  • Mar 28, 2007
  • Joined Mar 27, 2007
  • Thanks a lot for your reply big.nerd 🙂
    I understand the idea of that function, but I really don't have a clue how to implement. (way to much noob :eek: )
    Could you explain this more, if you have the time?

    Thanks very much,

    Dick

    • This php scriprt will (as many other scripts ) pick an image from a parsed config file.
      In my "index.php" multiple images should show up (randomly picked).
      That all works perfect...but I do not want an image to show up twice (or even more) at the same time.

      How do I accomplish that?...I have no idea howto...

      Thanks

      Dick

      Here are the files:

      rotator.php

      function showImage() {
      
      $ini_file = 'images.ini';
      # read the config file into an array or die trying
      $images = @parse_ini_file($ini_file,true);
      if (! $images) {
        die('cannot read ini file');
      }
      
      
      
      $img = array_rand($images);
      # get the selected image's css id if one exists
      $id = $images[$img]['id'] ?
        sprintf( ' id="%s" ', $images[$img]['id'] ) :
        '';
      # get selected image's dimensions
      $size = @getimagesize( $images[$img]['src'] );
      # if an url was specified, output the opening A HREF tag
      if ( $images[$img]['url'] ) {
        printf(
          '<a href="%s" title="%s" target="blank">',
          $images[$img]['url'],
          $images[$img]['title']
        );
      }
      # output the IMG tag
      printf(
        '<img src="%s" alt="%s" %s %s%s/ border="0">',
        $images[$img]['src'],
        $images[$img]['alt'],
        $size[3],
        $id,
        $class
      );
      # if an url was specified, output the closing A HREF tag
      if ( $images[$img]['url'] ) {
        echo('</a>');
      }	
        }

      images.ini

      [klaassen] 
      src   = img/klaassen.jpg 
      alt   = Jan Klaassen 
      url   = http://google.com/ 
      title = klaassen website 
      
      [Pietersen] 
      src   = img/pietersen.jpg 
      alt   = Jan Pietersen 
      url   = http://msn.com/ 
      title = Pietersen website 
      
      [Jansen] 
      src   = img/jansen.jpg 
      alt   = Jan Jansen 
      url   = http://php.com/ 
      title = Jansen website 
      
      [Mulder] 
      src   = img/mulder.jpg 
      alt   = Jan Mulder 
      url   = http://www.hotscripts.com 
      title = Mulder website 
      
      [Dekker] 
      src   = img/dekker.jpg 
      alt   = Jan Dekker 
      url   = http://www.voetbal.nl 
      title = Dekker website 
      
      [Gerritsen] 
      src   = img/gerritsen.jpg 
      alt   = Jan Gerritsen 
      url   = http://www.ilse.nl 
      title = Gerritsen website 
      
      [Van Dijk] 
      src   = img/dijk.jpg 
      alt   = Jan van Dijk 
      url   = http://www.maastricht.nl 
      title = Van Dijk website 

      index.php

      <?php include('rotator.php'); ?> 
      <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
      <body> 
      
      <p>refresh to see new images.</p> 
      
      <?php showImage(); ?> 
      
      <?php showImage(); ?> 
      
      
      </body> 
      <html>