[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: OT: Use of variables in HTML




On Sunday, April 6, 2003, at 08:10  am, Burkhard Ritter wrote:

On Fri, 4 Apr 2003, Kent West wrote:

Sorry for being so very Off-Topic, but you folks know _everything_ . . .
. :-)

Is there a way to use straight HTML or CSS (no perl, php, javascript,
cgi) to create a web page that has variables in it, like so:

     <body>
Today's winner is <var=WINNER/>! Congratulations, <var=WINNER/>!
Sorry, <var=LOSER/>.
     </body>

and then have a separate document that has variable definitions, like so:

WINNER: Dogbert Comicdog
LOSER: Dilbert Comicman

So that the web page, when rendered by a browser looks like so:

Today's winner is Dogbert Comicdog! Congratulations, Dogbert Comicdog!
Sorry, Dilbert Comicman.

Thanks for any suggestions!

--
Kent

Perhabs you might have a look at server-site-includes (ssi). I think it's
possible to do such things with these (there are, if I am right, some
include-commands to include another file in your document, what would be
exactly what you were looking for). Though, you have to enable them in
your webserver (probably apache). Php, etc would also do the trick.

Php is probably your best bet. There is a book called PHP and MySQL Web Development (Luke Welling and Laura Thomson) in which the first example you work through shows how to present conditional information on a web page. The php script looks like this:

<h2>Order Results</h2>
<?
  echo "<p>Order processed at ";
  echo date("H:i, jS F");
  echo "<br>";
    $totalqty = 0;
    $totalamount = 0.00;
      define ("TYREPRICE", 100);
      define ("OILPRICE", 10);
      define ("SPARKPRICE", 4);
  $totalqty = $tyreqty+$oilqty+$sparkqty;
 $totalamount = $tyreqty * TYREPRICE
                 + $oilqty * OILPRICE
                 + $sparkqty * SPARKPRICE;
  $totalamount = number_format($totalamount, 2);
  echo "<br>";
  echo "Items ordered:        ".$totalqty."<br>\n";
if( $totalqty == 0 )
{
   echo "<font color=red>";
   echo "You didn't order anything on the previous page!<br>";
   echo "</font>";
}
else
{
  echo "<p>Your order is as follows:<br>";
  echo "<br>";
  echo $tyreqty. " tyres<br>";
  echo $oilqty. " bottles of oil<br>";
  echo $sparkqty. " spark plugs<br>";
  echo "<br>";
}
echo "Subtotal:             $".$totalamount."<br>\n";
  $taxrate = 0.10;  // local sales tax is 10%
  $totalamount = $totalamount * (1 + $taxrate);
  $totalamount = number_format($totalamount, 2);
  echo "Total including tax:            $".$totalamount."<br>\n";
?>
</body>
</html>

Regards

Clive
____________________________
Who says middle America supports this act of aggression in the Middle East?:
http://www.alternet.org/story.html?StoryID=15453

What is it like to be an Iraqi in Baghdad?
http://www.dear_raed.blogspot.com/

Clive Menzies & Associates Limited
strategies for business
http://www.clivemenzies.co.uk
75 Priory Road, London N8 8LR
d/l: 020 8348 0996
fax: 087 0705 2066



Reply to: