Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Switching between style

Status
Not open for further replies.

mickey6499

IS-IT--Management
Mar 7, 2002
3
US
new to php and am having problems with this one...

I want to be able to switch between different <style type="text/css"> according to what the value of $_GET['xx'] is.

*****************************************************************
switch ($_GET['xx']) {
case 'abc':
echo '<style type="text/css">
#stylea {
font: bold 11px/14px Trebuchet MS, Arial, sans-serif;
color: #ffffff;
}
</style>';
break;
case 'xyz':
echo '<style type="text/css">
#styleb {
font: bold 11px/14px Trebuchet MS, Arial, sans-serif;
color: #000000;
}
</style>';
break;
}
*****************************************************************

I'm not sure how to get this to work.

Thanks.
 
Lots of ways to do this. This is one way you could do it (and still maintain some readability between php and html:
Code:
switch ($_GET['xx']) {
	case 'abc': { ?>
		<style type="text/css">
			#stylea {
				font: bold 11px/14px Trebuchet MS, Arial, sans-serif;
				color: #ffffff;
			}
		</style>
<?		break;
	}
	case 'xyz': { ?>
		<style type="text/css">
			#styleb {
				font: bold 11px/14px Trebuchet MS, Arial, sans-serif;
				color: #000000;
			}
		</style>
<?		break;
	}
}

Cheers,
Jeff

[tt]Jeff's Page [/tt][tt]@[/tt][tt] Code Couch
[/tt]

What is Javascript? faq216-6094
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top