[thelist] best way to do dynamic tabs in PHP
Tom Dell'Aringa
pixelmech at yahoo.com
Wed Jan 22 21:29:00 CST 2003
<snip> - my original question was how to best write out some tabs on
my page dynamically using php to show a selected tab or a normal tab.
--- Jackson Yee <jyee at vt.edu> wrote:
> That's pretty much the same way that I do it as well, Tom, only I
> tend to use a function along with descriptive names
> <?php
> function WriteTab($Link)
> {
> echo '<a href="/', $Link, '"><img="tab', $Link;
>
> if ($_SERVER['REQUEST_URI'] == $Link)
> {
> echo 'highlight';
> }
>
> echo '.png" width..."
> }
>
> WriteTab("foo");
> WriteTab("bar");
> ?>
Okay, I thought that was a great idea, so running with that I came up
with my function pasted below. It works great but I have a small
problem.
There is a space between my tabs which I can't have. This is because
I believe the each function call creates a new line or line break, so
i get code like:
<img tag>
<img tag>
etc
with white space in between..i need to get rid of that or I can't use
this..(they need to butt up together like)
<img tag><img tag>
--------------------------------------------------
function writeTab($link, $width, $height)
{
$page = basename($_SERVER['SCRIPT_NAME']);
$curpage = $link . ".php";
if($page == $curpage)
{?>
<img src="/_images/<?=$link?>_sel.gif" alt="<?=$link?>" border="0"
width="<?=$width?>" height="<?=$height?>" align="absbottom"
name="<?=$link?>" />
<?}
else
{?>
<a href="<?=$page?>" onmouseover="rollOver('<?=$link?>', 'on');"
onmouseout="rollOver('<?=$link?>', 'off');"><img
src="/_images/<?=$link?>_off.gif" width="<?=$width?>"
height="<?=$height?>" alt="<?=$link?>" border="0" align="absbottom"
name="<?=$link?>" /></a>
<?}
}
writeTab("home", "100", "36");
writeTab("parties", "115", "36");
writeTab("store", "100", "36");
------------------------------------------------------------
Thanks
Tom
=====
var me = tom.pixelmech.webDeveloper();
http://www.pixelmech.com/
http://www.maccaws.com/
[Making A Commercial Case for Adopting Web Standards]
__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com
More information about the thelist
mailing list