NameSilo

A handy bit of code

Spacemail by SpaceshipSpacemail by Spaceship
Watch

Barrucadu

Established Member
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.

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.
 
1
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
hehe! tricky code :D usefull if you are using dreamweaver...
...but I'm using notepad..or programmers notepad
 
0
•••
Thanks for the code. Very useful indeed.
 
0
•••
lepunk said:
:D usefull if you are using dreamweaver...

Yup, I got bored of trying to edit big pages with no stylesheet, lol
 
0
•••
Dynadot — .com Registration $8.99Dynadot — .com Registration $8.99
Appraise.net

We're social

Unstoppable Domains
Domain Recover
DomainEasy — Zero Commission
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back