PX : code

Picture viewer by David Morton
Download this code


<html>
<head>
<title>Photo Album</title>
<link rel=\\\\\\\"STYLESHEET\\\\\\\" type=\\\\\\\"text/css\\\\\\\" href=\\\\\\\"../mainpage.css\\\\\\\">
</head>
<body>
<h1>Photo Album</h1>
<?php

//  Picture displayer
// Written by David Morton (dmorton@pcug.org.au), 30 July 2001.
// This script presents a picture file in a web page, together with a selection list
// to allow selection of more pictures. It looks prettier than a simple JPEG file.
// It requires a text file (pics.txt) with a line for each picture in your album, of form:
//
// <a unique caption for the picture>**<the file name>**<some narrative to describe the picture>
//
// You can include HTML markup in the narrative if you want to.
// To use your style sheet to enhance the output modify line 4.
// Put this file, pics.txt and all your graphics files in one directory, and enjoy.

$piclist file("pics.txt\\\\\\\");  //The name of the text file containing picture data

foreach($piclist as $entry)
  { 
  $arr = explode(\\\\\\\"**\\\\\\\",$entry,3);
  $filelist[$arr[0]] = $arr[1];
  $narratives[$arr[0]] = $arr[2];
  }     

// Print Print image if from form, else default page
// asking for a selection.

if ($caption)  // A picture has been identified to display
  {
  $this_caption = $caption;
  echo \\\\\\\"<div align = \\\\\\\\\\\\\\\"center\\\\\\\\\\\\\\\"><div class=\\\\\\\\\\\\\\\"picframe\\\\\\\\\\\\\\\">
  <img src=\\\\\\\\\\\\\\\"$filelist[$this_caption]\\\\\\\\\\\\\\\" alt=\\\\\\\\\\\\\\\"$this_caption\\\\\\\\\\\\\\\"></div>
  <strong>$this_caption</strong></div>
  <p>$narratives[$this_caption]</p>\\\\\\\";
  }
else
  {
  echo \\\\\\\"<p>Welcome to our photo album. You can pick a picture to view
  by making a selection from the following list</p>\\\\\\\";
  $this_caption = \\\\\\\"\\\\\\\";
  }
?>
<form method=\\\\\\\"get\\\\\\\" action=\\\\\\\"album.php\\\\\\\">
<p><select name=\\\\\\\"caption\\\\\\\" size=10>
<?php
foreach (Array_Keys($filelist) as $key)
  {
  print \\\\\\\"<option\\\\\\\";
  if ($key == $this_caption)
    {
    print \\\\\\\" selected\\\\\\\";
    }
  print \\\\\\\">$key</option>\\\\\\\";
  }
?>
</select>
<input type=\\\\\\\"submit\\\\\\\" value=\\\\\\\"Show the picture\\\\\\\" ></p> 
</form>

<!-- put a navigation bar to the rest of the site here -->

</body></html>

Comments or questions?
PX is running PHP 5.2.17
Thanks to Miranda Productions for hosting and bandwidth.
Use of any code from PX is at your own risk.