If your components are calculating the same thing over and over again
for the requests that come in, there's probably something wrong with
the architecture!
<HTML>
<HEAD><TITLE>PHP & Databases</TITLE></HEAD>
<BODY>
<? require("$DOCUMENT_ROOT/navbars/header.html") ?>
<?
mysql_pconnect("localhost:3306","myuser","mypass");
$rs=mysql_db_query("mydb","
SELECT c.category_path, c.category_name
FROM story s, category c
WHERE s.story_id=$STORY_ID
AND c.category_id=s.category_id
");
$row=mysql_fetch_row($rs);
?>
<!-- link to the top page for this category -->
<A HREF="<? echo $row[0] ?>"><? echo $row[1] ?></A><BR>
<? require("$DOCUMENT_ROOT/navbars/footer.html") ?>
</BODY>
</HTML>
In this case, PHP code connecting to the database (circa PHP3 API) for every
request to calculated the link URL and link text for a link to the top level
page for the category the current story is in. This is an example of what
not to do!