help

Discussion in 'HTML/CSS' started by leigh, Jan 17, 2007.

  1. leigh Guest

    how do ya put a css in a html page or do it so css is connected to db so users can choose there own colours i only know how to do the colours in a page not using css
  2. sladmin CSNM Reseller

    Hi Leigh,

    No need to involve a database here just some CSS documents. What you need to do (I think) is have all of your pages colours and CSS properties in one whole document. By this I mean having the background colour, text styles, rollover styles ect in one CSS document. If you duplicate the CSS document and change the colour scheme save it so you have 2 CSS documents.

    I think that you can somehow tell where the web page gets its CSS from so all you need to do is provide a drop-down box with the two document styles in and make it so that it refreshes the page with the new style.

    I don't actually know exactly how this can be achieved but I think JAVA can do this or dynamic HTML. Take a look at www.dynamicdrive.com as they have hundreds of little scripts and dynamic effects. If you google it it should return loads of help sites to help you out ;)

    Hope this helps,
  3. Piercy Rather crap web designer

    You could also do it dynamically. Were you have the link to your CSS in the page like below

    Code:
    <link href="ss1.css" rel="stylesheet" type="text/css">
    you could then create this dynamically from a db so you could pick and choose the style sheet to use from a choice on your page
  4. Nick Irvine Secretly the main man

    You could do this very simply. Firstly create the css documents, call them what they are, i.e bluecss.css, greencss.css, etc

    Then create a form with a drop down menu, listing the values such as:

    PHP:
    <form id="form2" name="form2" method="get" action="<?php echo $_SERVER['php_self']?>">
          <label>
          <select name="css" id="css">
            <option value="bluecss.css">Blue</option>
            <option value="greencss.css">Green</option>
          </select>
          </label>
            <label>
            <input type="submit" name="Submit" value="Select" />
            </label>
        </form>
    The form sends the user back to the current page, thats the php self bit. But the page must be a .php file for this to work.

    Then on the page, under the title tag, use the following code to select the css file they want.
    PHP:
    <link href="<?php echo $css?>" rel="stylesheet" type="text/css" />
    This is the basic code, but you could use sessions to store there choice as currently it will only show on the one page. Or you could, as you suggest, use a database to store their choice permently as you have a userbase but this a little more complex.
  5. pureinfinity CSNM Customer

  6. sladmin CSNM Reseller

    That's a pretty good example. I have been looking for something like that for a while. Definitely useful for a CMS.

Share This Page