- Impact
- 64
Lets say, you let each user choose a theme, and the url of the css for that theme was stored in a database. If you are using dreamweaver and want your pages to look nice (ie: WITH a style sheet) while you edit them, use this code.
How this works is:
1) Dreamweaver sees the HTML and renders it.
2) The PHP parser sees the if statement if(1 == 2), 1 does not equal 2, so the html is not rendered.
3) Because 1 does not equal 2, the alternate style sheet is used instead.
Basicly, it uses your stylesheet when your editing it in dreamweaver, but another stylesheet when online.
PHP:
<?php
if(1 == 2){
?>
<head>
<link rel="stylesheet" href="default.css" type="text/css" />
</head>
<?php
}else{
echo '<head>
<link rel="stylesheet" href="' . $url_to_stylesheet . '" type="text/css" />
</head>';
}
?>
How this works is:
1) Dreamweaver sees the HTML and renders it.
2) The PHP parser sees the if statement if(1 == 2), 1 does not equal 2, so the html is not rendered.
3) Because 1 does not equal 2, the alternate style sheet is used instead.
Basicly, it uses your stylesheet when your editing it in dreamweaver, but another stylesheet when online.









