Simple PHP script

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jedispy

    #1

    Simple PHP script

    Hello,
    I'm pretty new to PHP, and for starters I want to create a simple script for
    creating dynamic web pages.
    Here is how I want it to work:
    index.html has 4 thumbnail images on it.
    When users click a thumbnail image, I want it to generate a dynamic web page
    that displays the image, and a caption.

    I'm not looking for anything fancy. I'm hoping that this can be done by
    simply calling the file and the text string (for the caption). I know this
    can be done utilizing a database, but I'm trying to see if PHP can handle it
    by simply calling the objects themselves.

    Can this be done? If so, how do I do it in PHP?

    Jedispy


  • Mike Discenza

    #2
    Re: Simple PHP script

    Jedispy wrote:
    [color=blue]
    > Hello,
    > I'm pretty new to PHP, and for starters I want to create a simple script
    > for creating dynamic web pages.
    > Here is how I want it to work:
    > index.html has 4 thumbnail images on it.
    > When users click a thumbnail image, I want it to generate a dynamic web
    > page that displays the image, and a caption.
    >
    > I'm not looking for anything fancy. I'm hoping that this can be done by
    > simply calling the file and the text string (for the caption). I know
    > this can be done utilizing a database, but I'm trying to see if PHP can
    > handle it by simply calling the objects themselves.
    >
    > Can this be done? If so, how do I do it in PHP?
    >
    > Jedispy[/color]


    It is probably more than what you are looking for but I have a couple of
    pages that do something like what you want. Feel free to take a look at
    them if you want.

    The first is the "photo browser"
    (http://barrelofmonkeys.sytes.net/sou...oBrowser.phps). This will
    read a directory for files that end in .desc. It parses them to get the
    information about the images from it, then uses that to build the contents
    of the page and display the images.

    The second page is the part that shows an enlarged image
    (http://barrelofmonkeys.sytes.net/source/showImage.phps). This is opened
    through some javascript on the first page and simply shows an enlarged
    image.

    This work well for what I use them for. Feel free to use what you can from
    the pages.

    Comment

    • Geoff Berrow

      #3
      Re: Simple PHP script

      I noticed that Message-ID: <10388co27q0dn8 8@corp.supernew s.com> from
      Jedispy contained the following:
      [color=blue]
      >Hello,
      >I'm pretty new to PHP, and for starters I want to create a simple script for
      >creating dynamic web pages.
      >Here is how I want it to work:
      >index.html has 4 thumbnail images on it.
      >When users click a thumbnail image, I want it to generate a dynamic web page
      >that displays the image, and a caption.
      >
      >I'm not looking for anything fancy. I'm hoping that this can be done by
      >simply calling the file and the text string (for the caption). I know this
      >can be done utilizing a database, but I'm trying to see if PHP can handle it
      >by simply calling the objects themselves.
      >
      >Can this be done? If so, how do I do it in PHP?[/color]

      This may give you some ideas.



      --
      Geoff Berrow (put thecat out to email)
      It's only Usenet, no one dies.
      My opinions, not the committee's, mine.
      Simple RFDs http://www.ckdog.co.uk/rfdmaker/

      Comment

      • Tim Tyler

        #4
        Re: Simple PHP script

        Jedispy <jedispy.remove .me@yahoo.remov e.me.com> wrote or quoted:
        [color=blue]
        > I'm pretty new to PHP, and for starters I want to create a simple script for
        > creating dynamic web pages.
        > Here is how I want it to work:
        > index.html has 4 thumbnail images on it.
        > When users click a thumbnail image, I want it to generate a dynamic web page
        > that displays the image, and a caption.
        >
        > I'm not looking for anything fancy. I'm hoping that this can be done by
        > simply calling the file and the text string (for the caption). I know this
        > can be done utilizing a database, but I'm trying to see if PHP can handle it
        > by simply calling the objects themselves.
        >
        > Can this be done? If so, how do I do it in PHP?[/color]

        Here's some demos of mine:




        Source is at:


        --
        __________
        |im |yler http://timtyler.org/ tim@tt1lock.org Remove lock to reply.

        Comment

        • Fred H

          #5
          Re: Simple PHP script

          På Wed, 18 Feb 2004 18:09:39 -0800, skrev Jedispy
          <jedispy.remove .me@yahoo.remov e.me.com>:
          [color=blue]
          > (...)
          > a simple script (...)
          > that displays the image, and a caption.
          > (...)
          > Can this be done? If so, how do I do it in PHP?[/color]

          ------ File show.php ---------------
          <html><body>
          <?php
          #Arrays to store image urls and captions:
          $images = array();
          $captions = array();

          #Put images and captions into the arrays.
          #NB: This must be done pair-wize, or images
          #and captions will become out of synch.

          #Add image one:
          array_push($ima ges,"http://www.url.com/images/img1.jpg");
          array_push($cap tions,"This is image one";

          #Add image two:
          array_push($ima ges,"http://www.url.com/images/img2.jpg");
          array_push($cap tions,"This is image two";

          #And so on...

          #Check if we can display an image and it's caption:
          if(isset($img) && is_numeric($img ) && isset($images[$img]) &&
          isset($captions[$img])) {
          #We can, so that's what we'll do:
          echo "<img src='$images[$img]'><br>$caption s[$img]<br>"
          }

          ?>
          </body></html>
          ------------------------------------

          If you now call show.php like this:
          http://www.domain.com/show.php?img=1
          show.php will display image number one, with it's caption.

          Now, you asked for "simple", and you got it. Simplar than
          this it probably can't be done :-)

          You would probably want to change how the image and the
          caption is displayed though.


          --
          Fred H

          void FredH::Contact( ) {
          TextToSpeach.sa y("frode at age dee dee dot en oh");
          }

          Comment

          Working...