Changing CSS with PHP

This is a discussion on "Changing CSS with PHP" within the PHP Forum section. This forum, and the thread "Changing CSS with PHP are both part of the Program Your Website category.



Go Back   Webforumz.com > Main Forums > Program Your Website > PHP Forum

Notices


Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old Oct 11th, 2007, 10:46
Emzi's Avatar
SuperMember

SuperMember
Join Date: Sep 2007
Location: Manchester
Age: 25
Posts: 148
Thanks: 0
Thanked 0 Times in 0 Posts
Changing CSS with PHP

I wasn't sure if I should post this in here or the CSS forum so I apologise if it's in the wrong place.

I have designed four layouts for a new project and I am going to have an option for people to change the layout.

This will change the CSS and in turn change the look and feel of the site altogether.

I have searched on google for ways to do this in PHP but the ones I tried didn't work properly.

Does anyone know how I can do this or point me in the right direction?

Thanks
Reply With Quote

  #2 (permalink)  
Old Oct 11th, 2007, 10:55
SuperMember

SuperMember
Join Date: May 2007
Location: UK
Age: 27
Posts: 1,111
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Changing CSS with PHP

Use javascript.
Reply With Quote
  #3 (permalink)  
Old Oct 11th, 2007, 10:57
Emzi's Avatar
SuperMember

SuperMember
Join Date: Sep 2007
Location: Manchester
Age: 25
Posts: 148
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Changing CSS with PHP

Quote:
Originally Posted by MikeHopley View Post
Hi, thanks for that.

I had just been looking around here in the CSS forum and someone had posted how to do it in JavaScript rather than PHP so I gave it a go and it worked
Reply With Quote
  #4 (permalink)  
Old Oct 11th, 2007, 10:58
Rakuli's Avatar
SuperMember

SuperMember
Join Date: Sep 2007
Location: Australia
Age: 24
Posts: 956
Blog Entries: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Changing CSS with PHP

This would be easy to achieve with PHP. If you send the name of the css of the query string

Say you send the css name like thisismyurl.php?style=css1

then in your php

PHP: Select all

$style 'css1';


// Store the style choice into the session to carry it around pages
if (!empty($_GET['style']))
    
$_SESSION['style'] = $_GET['style'];


// Now choose the selected style
switch ($_SESSION['style'])
{
    case 
'css1' :
         
$style'css1';
         break;
    case 
'css2' :
        
$style 'css2';
        break;
    case 
'css3' :
        
$style 'css3';
        break;
    case 
'css4' :
        
$style 'css4';
        break;
}

// ECho the required style
echo '<link type="text/css" rel="stylesheet' href="', $style, '" />; 
Hope that helps,

Cheers.
Last Blog Entry: The wannabe juggler's quest (Oct 27th, 2007)
Reply With Quote
  #5 (permalink)  
Old Oct 11th, 2007, 17:03
alexgeek's Avatar
Technical Administrator

SuperMember
Join Date: Jul 2007
Location: Webforumz 24/7
Age: 15
Posts: 3,770
Blog Entries: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to alexgeek
Re: Changing CSS with PHP

Rakuli, wouldn't it be easy for the user to save it in a session?
That way you would not need to append GETs to every page.
Last Blog Entry: 3D Chess in your browser! (Mar 14th, 2008)
Reply With Quote
  #6 (permalink)  
Old Oct 11th, 2007, 20:54
Rakuli's Avatar
SuperMember

SuperMember
Join Date: Sep 2007
Location: Australia
Age: 24
Posts: 956
Blog Entries: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Changing CSS with PHP

Quote:
Originally Posted by alexgeek View Post
Rakuli, wouldn't it be easy for the user to save it in a session?
That way you would not need to append GETs to every page.
Quote:
Originally Posted by Rakuli
PHP: Select all

$style 'css1';


// Store the style choice into the session to carry it around pages
if (!empty($_GET['style']))
    
$_SESSION['style'] = $_GET['style']; 
Last Blog Entry: The wannabe juggler's quest (Oct 27th, 2007)
Reply With Quote
  #7 (permalink)  
Old Oct 11th, 2007, 22:45
Reputable Member
Join Date: Apr 2007
Location: Scotland
Age: 17
Posts: 233
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Blake121
Re: Changing CSS with PHP

There's a good tutorial coming out on this topic in the next newsletter.

You can get a full explanation and tutorial there
Reply With Quote
  #8 (permalink)  
Old Oct 11th, 2007, 23:24
alexgeek's Avatar
Technical Administrator

SuperMember
Join Date: Jul 2007
Location: Webforumz 24/7
Age: 15
Posts: 3,770
Blog Entries: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to alexgeek
Re: Changing CSS with PHP

Quote:
Originally Posted by Blake121 View Post
There's a good tutorial coming out on this topic in the next newsletter.

You can get a full explanation and tutorial there
On what? Sessions/Gets or multiple stylesheets?
Last Blog Entry: 3D Chess in your browser! (Mar 14th, 2008)

Last edited by alexgeek; Oct 11th, 2007 at 23:24. Reason: Learn to spell alex! ;)
Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Changing career DPhahn Introduce Yourself 24 Aug 9th, 2007 18:15
changing pic's bruno89 Web Page Design 4 Sep 8th, 2006 15:22
Changing cell id? moojoo JavaScript Forum 2 Aug 30th, 2006 20:16
changing %20 in URL using PHP JamieH PHP Forum 1 Dec 8th, 2005 13:52
Help changing the WHERE Variable? courtjester Databases 5 Jun 2nd, 2004 15:35


All times are GMT. The time now is 20:48.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43