CSS in PHP - Howto ?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
sacfreak
Forum Newbie
Posts: 6
Joined: Tue Mar 11, 2003 3:10 am

CSS in PHP - Howto ?

Post by sacfreak »

hi again,
i use HTML embedded in PHP. i would like to use CSS references in my script...but the normal way.....like used in HTML is not working...here is a section of my code...

echo"<html><HEAD><LINK REL=StyleSheet HREF=sitestyle.css TYPE=css></HEAD> .................
..........<TR><TD CLASS=labelbg><SPAN CLASS=label>Institue Name- </SPAN></TD><TD>$sessInstName</TD>";

an html page using the same code is working fine...... please help me out...
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

open the requested document in your browser's source view.
If it exactly looks like the working static html-document, it's the same for the browser.
btw: you can enter and leave php blocks (almost) as you want. Everything outside a php-block is sent "as is" to the client.
e.g.

Code: Select all

<?php
// some php-code here
?>
<html>
	<head>
		<link rel="StyleSheet" href="sitestyle.css" type="css">
	</head>
	<body>
		.................
		..........
		<TR>
			<TD CLASS="labelbg">
				<SPAN CLASS="label">Institue Name-</SPAN>
			</TD>
			<TD>
				<?php echo $sessInstName; ?>
			</TD>
		...
User avatar
m3mn0n
PHP Evangelist
Posts: 3548
Joined: Tue Aug 13, 2002 3:35 pm
Location: Calgary, Canada

Post by m3mn0n »

this works too. :wink:

Code: Select all

<?php
// some php-code here
?>
<html>
	<head>
		<link rel="StyleSheet" href="sitestyle.css" type="css">
	</head>
	<body>
		.................
		..........
		<TR>
			<TD CLASS="labelbg">
				<SPAN CLASS="label">Institue Name-</SPAN>
			</TD>
			<TD>
				<?=$sessInstName?>
			</TD>
		...
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

Oromian wrote:this works too. :wink:

Code: Select all

<?=$sessInstName?>
If you have open short tags enabled, which is not a given :wink:

Mac
McGruff
DevNet Master
Posts: 2893
Joined: Thu Jan 30, 2003 8:26 pm
Location: Glasgow, Scotland

Post by McGruff »

I like to include separate html templates: keeps the code separate from the formatting. This lets designers do their thing and coders do theirs - but it's not essential. Try a google search for nTier - sorry lost a link I could have given you.

Don't forget the quotes ie <a href="..etc..">
Post Reply