Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

PHP and Changing CSS

Options
  • 23-02-2010 1:44pm
    #1
    Registered Users Posts: 23,641 ✭✭✭✭


    I am trying to let users change style on my website. I have had success in Opera were when the user selects a style it changes to match their selection. This is done through a PHP Switch process.

    [PHP]<?php
    if (isset($_POST))
    {
    $layout = $_POST;
    }

    switch ($layout) {
    case 'main':
    echo '<link href="../_css/main.css" rel="stylesheet" type="text/css" title ="menuc" />';
    echo "\n";
    break;
    case 'meunc':
    echo '<link href="../_css/menuc.css" rel="stylesheet" type="text/css" title ="menuc" />';
    echo "\n";
    break;
    case 'row':
    echo '<link href="../_css/row.css" rel="stylesheet" type="text/css" title ="menuc" />';
    echo "\n";
    break;
    Default:
    echo '<link href="../_css/main.css" rel="stylesheet" type="text/css" title ="menuc" />';
    echo "\n";
    break;
    }

    ?>[/PHP]

    The resulting HTML at default is

    [HTML]<link href="../_css/main.css" rel="stylesheet" type="text/css" title ="menuc" />[/HTML]

    How ever for some reason all browsers except Opera will not accept the HTML Code, but will change the HTML code and will have the default html on entering the site. Chrome seems to not recognize the PHP Switch statement at all, but does show the default CSS file link in the HTML code.


Comments

  • Registered Users Posts: 23,641 ✭✭✭✭Elmo


    It seems the title was an issue for the html code.

    <link href="../_css/main.css" rel="stylesheet" type="text/css" title ="menuc" />


  • Registered Users Posts: 6,509 ✭✭✭daymobrew


    Elmo wrote: »
    How ever for some reason all browsers except Opera will not accept the HTML Code, but will change the HTML code and will have the default html on entering the site. Chrome seems to not recognize the PHP Switch statement at all, but does show the default CSS file link in the HTML code.
    You say that "Chrome seems to not recognize the PHP Switch statement at all" - PHP is server side, not client/browser side. No browser will process PHP code.

    Do you have a link to the problem page?


  • Registered Users Posts: 23,641 ✭✭✭✭Elmo


    daymobrew wrote: »
    You say that "Chrome seems to not recognize the PHP Switch statement at all" - PHP is server side, not client/browser side. No browser will process PHP code.

    Sorry that was just my bad description of the problem. I have fixed it now thanks for your help. The other browsers seemed to have an issue with title in the CSS link.


  • Registered Users Posts: 6,509 ✭✭✭daymobrew


    Elmo wrote: »
    Sorry that was just my bad description of the problem. I have fixed it now thanks for your help. The other browsers seemed to have an issue with title in the CSS link.
    I don't think that it is a valid attribute for the link element.

    You can always put your pages through the W3C Validator to find out.


Advertisement