Activity Stream
48,167 MEMBERS
6988 ONLINE
besthostingforums On YouTube Subscribe to our Newsletter besthostingforums On Twitter besthostingforums On Facebook besthostingforums On facebook groups

Results 1 to 7 of 7
  1.     
    #1
    Member

    Default how implement css in php

    am currently doing a project in php,but i dont know how to implement css in php,can anybody help me?
    rashid Reviewed by rashid on . how implement css in php am currently doing a project in php,but i dont know how to implement css in php,can anybody help me? Rating: 5

  2.   Sponsored Links

  3.     
    #2
    Member
    Website's:
    sborg.us
    No wait, what?

    CSS => used in HTML.

    PHP => Server side script, won't be shown to the user unless you embed HTML code in it.

    You may wanna check this link: http://www.johnhaydon.com/2011/03/wh...-css-html-php/

    V3g3ta | Halcyon | Abhi

  4.     
    #3
    Member
    Website's:
    somik.org sborg.us
    Ignore the previous comment. This is how to do it.


    Code: 
    
    <?php
    
    echo ".body{";
    echo "    background-color:". get_background_color() .";";
    echo "    background-image: url(". get_background_image() .");";
    echo "}";
    
    ?>

    This is a short example. Be sure to define seperate functions for each property.

  5.     
    #4
    Respected Member
    Very bad example somik. Also Halcyon was correct in what he said.
    Here is a proper example ..
    PHP Code: 
    <?php
    echo <<<HTML
    <html>
    <head>
    <style>

    a { display: block; }
    p { display: inline; }

    </style>
    </head>
    <body>
    <h2>CSS Display</h2>
    <a href="http://www.tizag.com/" target="_blank" class="disp1">Tizag.com - Learn to Whip the Web</a>
    <a href="http://www.tizag.com/" target="_blank" class="disp1">Tizag.com - Learn to Whip the Web</a>
    <a href="http://www.tizag.com/" target="_blank" class="disp1">Tizag.com - Learn to Whip the Web</a>
    <a href="http://www.tizag.com/" target="_blank" class="disp1">Tizag.com - Learn to Whip the Web</a>
    <a href="http://www.tizag.com/" target="_blank" class="disp1">Tizag.com - Learn to Whip the Web</a>
    <br />
        <p class="disp1">These paragraph </p>
        <p class="disp1">elements </p>
        <p class="disp1">have been </p>
        <p class="disp1">inlined.</p>
    </body>
    </html>
    HTML;
    ?>

  6.     
    #5
    Member
    You would be best of trying to use some kind of templating system. Then you can separate the two.

  7.     
    #6
    Member
    Website's:
    somik.org sborg.us
    Quote Originally Posted by Lock Down View Post
    Very bad example somik.
    LOL!



    Okies, so this is how i usually write the codes:

    PHP Code: 
    <?php

    /**
     * @author Somik
     * @copyright 2012
     */

    // main PHP codes goes here

    setcookie("test",$testvalue);

    ?>
    <!DOCTYPE HTML>
    <html>
    <head>
        <meta http-equiv="content-type" content="text/html" />
        <meta name="author" content="Somik" />

        <title>Untitled 2</title>
        <style type="text/css">
        body{
            background-color: black;
            background-image: url(/path/to/image.jpg);
        }
        .tbl_main{
            border: 0px;
            border-collapse: collapse;
        }
        </style>
        <script type="text/javascript">
        // Javascript goes here
        </script>
    </head>

    <body>

    <table class="tbl_main">
      <tr>
        <td>
          <?php echo $value[1]; ?>
        </td>
        <td>
          <?php echo $value[1]; ?>
        </td>
      </tr>
      <tr>
        <td colspan="2">
          <?php myfunction($data1$data2); ?>
        </td>
      </tr>
    </table>


    </body>
    </html>

    <?php

    // PHP functions goes here

    function myfunction($data1$data2){
        echo 
    $data1 $data2;
    }

    ?>

    Yes, you can break the php codes with ?> and write HTML, CSS, javascript and whatever you need. Then when you need PHP again, just put it in between PHP tags <?php and ?>

    Follow instructions on this site for more info: http://www.tizag.com/phpT/

  8.     
    #7
    Member
    Website's:
    sborg.us
    Quote Originally Posted by somik View Post
    LOL!

    Yes, you can break the php codes with ?> and write HTML, CSS, javascript and whatever you need. Then when you need PHP again, just put it in between PHP tags <?php and ?>

    Follow instructions on this site for more info: http://www.tizag.com/phpT/

    No wonder why I end up in a mess whenever I see your codes!

    It is a good practice to separate the html and the server side activities. Coz the user doesn't need to know what happens when he/she loads a page!

    MVC pattern (en.wikipedia.org/wiki/Model?view?controller) was introduced to take care of this in the first place.


    P.S: You need not introduce MVC concepts in a small application (or script) but it may help you out in the long run

    V3g3ta | Halcyon | Abhi

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [Hiring] Want someone to implement a video-section
    By wraum in forum Completed Transactions
    Replies: 2
    Last Post: 8th Oct 2011, 10:05 PM
  2. How to implement CPA Lead on vbulletin?
    By adanrott in forum Webmasters, Money Making
    Replies: 4
    Last Post: 26th Oct 2010, 03:57 AM
  3. How to implement referral system ?
    By arunkumar2006 in forum phpBB
    Replies: 2
    Last Post: 15th Jun 2008, 04:14 PM

Tags for this Thread

BE SOCIAL