Specifications

{
echo “<table width = \”100%\” bgcolor = white”
.” cellpadding = 4 cellspacing = 4>\n”;
echo “ <tr>\n”;
//calculate button size
$width = 100/count($buttons);
while (list($name, $url) = each($buttons))
{
$this -> DisplayButton($width, $name, $url,
!$this->IsURLCurrentPage($url));
}
echo “ </tr>\n”;
echo “</table>\n”;
}
function IsURLCurrentPage($url)
{
if(strpos( $GLOBALS[“SCRIPT_NAME”], $url )==false)
{
return false;
}
else
{
return true;
}
}
function DisplayButton($width, $name, $url, $active = true)
{
if ($active)
{
echo “<td width = \”$width%\”>
<a href = \”$url\”>
<img src = \”s-logo.gif\” alt = \”$name\” border = 0></a>
<a href = \”$url\”><span class=menu>$name</span></a></td>”;
}
else
{
echo “<td width = \”$width%\”>
<img src = \”side-logo.gif\”>
<span class=menu>$name</span></td>”;
}
Using PHP
P
ART I
164
LISTING 6.1 Continued
08 7842 CH06 3/6/01 3:34 PM Page 164