CSS and PHP

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • IchBin

    CSS and PHP

    Sorry, I am a Java programmer and very new to php and was wondering with
    these questions. How do you typically integrate CSS into a PHP script.
    Do you embed it or reference a external CSS file? Have an include script
    to dynamically generate it. How do you have it work with a HTML FORM?
    Sorry, I have no clue as of yet. I have just started to research it.

    I have written the php code for my quotation test site. I want to start
    to format it via css. I have just built and playing with it at


    Also, any tips and Preferred Resources?

    --
    Thanks in Advance... http://ichbin.9999mb.com
    IchBin, Pocono Lake, Pa, USA http://weconsultants.phpnet.us
    _______________ _______________ _______________ _______________ __________
    'If there is one, Knowledge is the "Fountain of Youth"'
    -William E. Taylor, Regular Guy (1952-)
  • Rik

    #2
    Re: CSS and PHP

    IchBin wrote:
    Sorry, I am a Java programmer and very new to php and was wondering
    with these questions. How do you typically integrate CSS into a PHP
    script. Do you embed it or reference a external CSS file? Have an
    include script to dynamically generate it. How do you have it work
    with a HTML FORM? Sorry, I have no clue as of yet. I have just
    started to research it.
    PHP is not linked to CSS in any way.
    PHP generates/handles code, and spews back what's asked of it. If you want
    the output html documents, just make sure there's a correct link in the
    header like with static HTML documents.

    Both HTML & CSS are rendered in the client's browser, so all you have to do
    is provide the correct output.
    --
    Rik Wasmus


    Comment

    • Moot

      #3
      Re: CSS and PHP

      It is generally a good idea to link to an external CSS file. Having
      all your pages point to one file makes changes much easier than having
      to change it in every file.

      But this is a basic html/css issue, not very closely related to php.

      Comment

      • IchBin

        #4
        Re: CSS and PHP

        Michael Vilain wrote:
        In article <teacnbk99Ze3n9 zYUSdV9g@ptd.ne t>, IchBin <weconsul@ptd.n et>
        wrote:
        >
        >Sorry, I am a Java programmer and very new to php and was wondering with
        >these questions. How do you typically integrate CSS into a PHP script.
        >Do you embed it or reference a external CSS file? Have an include script
        >to dynamically generate it. How do you have it work with a HTML FORM?
        >Sorry, I have no clue as of yet. I have just started to research it.
        >>
        >I have written the php code for my quotation test site. I want to start
        >to format it via css. I have just built and playing with it at
        >http://ichbinquotations.awardspace.com
        >>
        >Also, any tips and Preferred Resources?
        >
        CSS and HTML are the "output" of whatever sever-side programming
        language you're using to generate that output. If you're using some
        sort of templating system, use it's constructs. Otherwise, this is up
        to how you've designed the program.
        >
        You can buy lots of books on HTML and CSS from lots of places. I like
        the O'Reilley and Sitepoint offerings.
        >
        YMMV.
        >
        Thanks for all of your replies...

        For this particular group of scripts I am not using any templating.
        I should have been clearer. Guess my question was not about the natures
        of CSS\HTML\PHP. I understand those.

        Looking for tips on usual way to tightly couple them to my advantage.
        PHP is not linked to CSS but they can be tightly coupled. PHP works on
        the server side but can also present the client side presentation. In
        this presentation I wanted to interlace HTML, CSS and PHP code.

        Is this a viable approach? I realize their are no standards in PHP but
        their must be more efficient ways, that have floated to the top, to
        approach what I am trying to do..? Or is this the right approach?

        This maybe a basic html/css issue but when I tightly couple it with PHP
        I see questions?

        Maybe with this perspective this would be a better way to ask my
        questions. :shock:

        My sources for documentation has been the W3C Recommendations for HTML
        and CSS.

        --
        Thanks in Advance... http://ichbin.9999mb.com
        IchBin, Pocono Lake, Pa, USA http://weconsultants.phpnet.us
        _______________ _______________ _______________ _______________ __________
        'If there is one, Knowledge is the "Fountain of Youth"'
        -William E. Taylor, Regular Guy (1952-)

        Comment

        • Rik

          #5
          Re: CSS and PHP

          IchBin wrote:
          For this particular group of scripts I am not using any templating.
          I should have been clearer. Guess my question was not about the
          natures
          of CSS\HTML\PHP. I understand those.
          >
          Looking for tips on usual way to tightly couple them to my advantage.
          PHP is not linked to CSS but they can be tightly coupled. PHP works on
          the server side but can also present the client side presentation. In
          this presentation I wanted to interlace HTML, CSS and PHP code.
          So? Make your CSS (either dynamic with PHP, or a static CSS file), spit out
          the HTML with PHP, et voilá.
          Is this a viable approach? I realize their are no standards in PHP but
          their must be more efficient ways, that have floated to the top, to
          approach what I am trying to do..? Or is this the right approach?
          We're not sure what you're trying to do. You have a couple of pages, with
          HTML output from PHP, and want to use CSS for them. There is no difference
          in static/dynamic output as soon as it's at the client....
          This maybe a basic html/css issue but when I tightly couple it with
          PHP I see questions?
          WHAT do xou couple with PHP? HOW? It's pretty much a one way street PHP ->
          HTML (possibly CSS), that's not a coupling IMO.
          --
          Rik Wasmus


          Comment

          • IchBin

            #6
            Re: CSS and PHP

            Rik wrote:
            IchBin wrote:
            >For this particular group of scripts I am not using any templating.
            >I should have been clearer. Guess my question was not about the
            >natures
            >of CSS\HTML\PHP. I understand those.
            >>
            >Looking for tips on usual way to tightly couple them to my advantage.
            >PHP is not linked to CSS but they can be tightly coupled. PHP works on
            >the server side but can also present the client side presentation. In
            >this presentation I wanted to interlace HTML, CSS and PHP code.
            >
            So? Make your CSS (either dynamic with PHP, or a static CSS file), spit out
            the HTML with PHP, et voilá.
            >
            >Is this a viable approach? I realize their are no standards in PHP but
            >their must be more efficient ways, that have floated to the top, to
            >approach what I am trying to do..? Or is this the right approach?
            >
            We're not sure what you're trying to do. You have a couple of pages, with
            HTML output from PHP, and want to use CSS for them. There is no difference
            in static/dynamic output as soon as it's at the client....
            Actually it is only one page that is presented. Sorry I have not
            explained what I am going to try to do. I have a lot of other objects I
            want to add to this page. Guess it is my lack of knowledge of CSS and
            the serial output from the server and how to place the data on my one
            html output. I am looking at XMLHttpRequest but I hear a lot from others
            that you should not use javascript because users can set it of in their
            browser. Then again their seems to be a lot of Javascript running on the
            net. Little confusing on my part.
            >
            >This maybe a basic html/css issue but when I tightly couple it with
            >PHP I see questions?
            >
            WHAT do xou couple with PHP? HOW? It's pretty much a one way street PHP ->
            HTML (possibly CSS), that's not a coupling IMO.
            I guess I see it as coupling because the PHP print\echo statements are
            passing the front end along with the php server side data output.

            --
            Thanks in Advance... http://ichbin.9999mb.com
            IchBin, Pocono Lake, Pa, USA http://weconsultants.phpnet.us
            _______________ _______________ _______________ _______________ __________
            'If there is one, Knowledge is the "Fountain of Youth"'
            -William E. Taylor, Regular Guy (1952-)

            Comment

            • Jerry Stuckle

              #7
              Re: CSS and PHP

              IchBin wrote:
              Sorry, I am a Java programmer and very new to php and was wondering with
              these questions. How do you typically integrate CSS into a PHP script.
              Do you embed it or reference a external CSS file? Have an include script
              to dynamically generate it. How do you have it work with a HTML FORM?
              Sorry, I have no clue as of yet. I have just started to research it.
              >
              I have written the php code for my quotation test site. I want to start
              to format it via css. I have just built and playing with it at

              >
              Also, any tips and Preferred Resources?
              >
              As others have noted, there really isn't a close tie between PHP and CSS.

              PHP just creates HTML and sends it to the client. Nothing more, nothing
              less.

              Build a sample static page first, and get it to look like you wish. You
              can get help from alt.html and/or alt.html.css.

              Then go back and replace the appropriate static elements with PHP
              generated code. They should look exactly the same.

              --
              =============== ===
              Remove the "x" from my email address
              Jerry Stuckle
              JDS Computer Training Corp.
              jstucklex@attgl obal.net
              =============== ===

              Comment

              • NC

                #8
                Re: CSS and PHP

                IchBin wrote:
                >
                How do you typically integrate CSS into a PHP script.
                Do you embed it or reference a external CSS file?
                Either or both; just like in HTML. Additionally, PHP allows you
                to generate CSS dynamically.

                Let's say your HTML/PHP/whatever files have this tag:

                <LINK rel="stylesheet " href="style.php " type="text/css">

                Then, inside stytle.php, you may write, for example:

                header('Content-Type: text/css');
                switch ($_GET['palette']) {
                case 'blueandyellow' :
                $b = '#0000ff';
                $c = '#ffff00';
                break;
                case 'greenandsilver ':
                $b = 'green';
                $c = 'silver';
                break;
                default:
                $b = '#ffffff';
                $c = '#000000';
                }
                echo <<<EOCSS
                body {
                color: $c;
                backrgound-color: $b;
                }
                <!-- Many other styles go here -->
                EOCSS;

                Then, you can switch the color palette (or any other attributes
                derfined
                by the stylesheet) is as easy as going from

                <LINK rel="stylesheet " href="style.php ?palette=bluean dyellow"
                type="text/css">

                to

                <LINK rel="stylesheet " href="style.php ?palette=greena ndsilver"
                type="text/css">

                The standard recommendation is to put as much style information
                into an external stylesheet as possible and suggest that the clients
                cache the stylesheet. This way, the stylesheet gets requested only
                once.
                Also, any tips and Preferred Resources?
                The CSS Specificatoin is your friend:



                Cheers,
                NC

                Comment

                • R. Rajesh Jeba Anbiah

                  #9
                  Re: CSS and PHP

                  IchBin wrote:
                  How do you typically integrate CSS into a PHP script.
                  Do you embed it or reference a external CSS file?
                  Always, single and external (and, other styles for other media(say,
                  print) and alternate styles).

                  <snip>
                  Also, any tips and Preferred Resources?
                  The current trend in web dev is the templating via CSS (esp, with
                  XHTML)--in which the position of HTML elements are "controlled " with
                  CSS. For the real world example, check
                  <http://www.mezzoblue.c om/zengarden/alldesigns/(you'll see, the HTML
                  remains same, but only the CSS file is changed externally).

                  For beginner <http://www.webdesignfr omscratch.com/and then lot of
                  links at mozilla dev corner like
                  <http://developer.mozil la.org/en/docs/Writing_Efficie nt_CSS>

                  --
                  <?php echo 'Just another PHP saint'; ?>
                  Email: rrjanbiah-at-Y!com Blog: http://rajeshanbiah.blogspot.com/

                  Comment

                  Working...