<?php // -*- Mode: PHP -*-
/*
 * $Header: /home/gene/library/website/docsrc/cssdemo/RCS/index.php,v 395.1 2008/04/20 17:25:50 gene Exp $
 *
 * Fetch & normalize the arguments.
 */
switch ($_GET["cssname"]) {
 case "red": $cssname = "red"; break;
 case "green": $cssname = "green"; break;
 case "blue": $cssname = "blue"; break;
 default: $cssname = "";
}
?><html>
<!--
  Copyright (c) 2007 Gene Michael Stover.  All rights reserved.
  Permission to copy, store, transmit, & view this document unmodified &
  in its entirety is granted.
-->
<head>
<?php
//
// Emit a style sheet name if & only if the style sheet name
// isn't an empty string.  Otherwise (it's an empty string),
// so save a little space by omitting the STYLE block.
//
if ($cssname != "") {
  printf ("<style><!-- ");
  printf ("@import url{%s.css};", $cssname);
  printf (" --></style>\n");
}
?>
<title>A Little CSS Demo</title>
</head><body>
<h1>A Little CSS Demo</h1>
<?php
if ($cssname != "") {
  printf ("<p>CSS name is &quot;%s&quot;.</p>\n", $cssname);
}
?>
<div id="TheForm">
<form action="index.php" method=GET>
<ul>
<?php
$lst = array ("red", "green", "blue");
foreach ($lst as $x) {
  printf ("<li>");
  printf ("<input type=radio name=cssname");
  if ($cssname == $x) printf (" checked");
  printf (" value=%s>", $x);
  printf ("%s", $x);
  printf ("</input></li>\n");
}
?>
</ul>
<input type=submit></form></div>
<div id="TheTable">
<table border=1>
<tr><th>header</th> <th>value</th></tr>
<?php
foreach ($_SERVER as $header => $value) {
  printf ("<tr>");
  printf ("<td align=right>%s</td>", htmlentities ($header));
  printf (" <td>");
  if (is_array ($value)) {
    // For arrays, we print each item into the single TD
    // node.
    foreach ($value as $y) {
      printf (" %s", htmlentities ($y));
    }
  } else {
    printf ("%s", htmlentities ($value));
  }
  printf ("</td>");
  printf ("</tr>\n");
}
?>
</table></div>
</body></html>
