Results 1 to 11 of 11

Thread: color

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Sep 2005
    Posts
    1,364

    color

    PHP Code:
    echo $row[0] . "=" $row[1] . " " $row[2] . " " $row[3] . "<br>"
    how do i color that entry red guys?
    Last edited by Pouncer; Jun 29th, 2006 at 07:42 AM.

  2. #2
    PowerPoster kfcSmitty's Avatar
    Join Date
    May 2005
    Posts
    2,248

    Re: color

    PHP Code:
    echo "<font color='#FF0000'> . $row[0] . "=" . $row[1] . " " . $row[2] . " " . $row[3] . "</font><br>"; 

    The above will work. But I would suggest using CSS and adding it through that.

    IE)

    HTML Code:
    <style>
    .fontStyle{
    font-color:#FF0000;}
    </style>
    and the php code would be

    PHP Code:
    echo "<p class='fontStyle'>" $row[0] . "=" $row[1] . " " $row[2] . " " $row[3] . "</p><br>"
    HTH

  3. #3
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: color

    If you're using a <p> tag you don't need the <br>.

  4. #4
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906

    Re: color

    Use cololurthatred tags:
    Code:
    <colorThatRed>My Red coloured Text</colorTheRed>
    Then use an XSL stylesheet to transform it into XHTML and for the love of god, stop using echo to output HTML.
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

  5. #5
    Hyperactive Member PlaGuE's Avatar
    Join Date
    Jun 2005
    Location
    in ur mind.
    Posts
    445

    Re: color

    Quote Originally Posted by visualAd
    ... and for the love of god, stop using echo to output HTML.
    I have yet to find any evidence saying tahts its bad....Even Books do it.
    Without balance, there could only be chaos.
    Without chaos, there could be no balance.
    I live with karma. Eat with destiny. Dream of life without shackles....
    Yet. If life had no consequences, life could not exist, nor could it flourish.


    If at first you dont succeed.You're screwed.

    C++/Java NOOB.

    I aint a professional at PHP, but if i can help i will.

  6. #6
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: color

    Oh dear.

    • PHP is designed to manipulate HTML.
    • Therefore PHP is designed to output in the first place.
    • Outputting via echo() destroys readability of the HTML.
    • You cannot easily distinguish between logic, and presentation.
    • Putting HTML in string literals kills any hope of syntax checking/colouring in editors.
    • Attribute quotes need to be escaped (depending on the type of string you use).
    • Closing PHP tags is quick, because all the HTML code can be skipped by the PHP parser until it reaches another opening PHP tag. Strings must be parsed for escape sequences, and, in the case of double-quoted strings, variables.


    I am sure there are more reasons, those are just off the top of my head right now.

    See, I could write a book on elephant sphincters but that doesn't make me an expert on the subject.

  7. #7
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906

    Re: color

    If you write a large PHP application you will soon see why it is a bad thing. I have said many times why it is bad. It requires that the parser carry out unneccessary processing, it makes the code look untidy and hard to read, it makes refactoring the application almost impossible, if using XHTML and CSS it destroys its portability and extensibility and it makes the HTML output look terrible.

    As for books using it, I am the progress of slaying a book I was asked to review for that very reason (I am sure the editor is going to love me ). PHP coders soon learn how to write the code properly and it is all too easy to ignore those beginners who struggle because the authors of books and tutorials are too lazy to write good sample code.
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

  8. #8
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906

    Re: color

    Further more, an XML document containing PHP programming instructions is a valid document and can be validated as such.
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

  9. #9

    Thread Starter
    Frenzied Member
    Join Date
    Sep 2005
    Posts
    1,364

    Re: color

    Quote Originally Posted by visualAd
    Use cololurthatred tags:

    Then use an XSL stylesheet to transform it into XHTML and for the love of god, stop using echo to output HTML.
    what should i use then mate?

  10. #10
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906

    Re: color

    Take a look at this:

    http://php5.codedv.com/library_xml/v...ion.php?source

    Notice how all output is at the bottom of the script and the processing is at the top. Notice also how only data from PHP is echoed and the rest of the HTML exists outside the <?php ?> tags.
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

  11. #11
    Hyperactive Member PlaGuE's Avatar
    Join Date
    Jun 2005
    Location
    in ur mind.
    Posts
    445

    Re: color

    Hmm...I never knew that. Thanks..Pengate and VisualAd.

    In my current project I'm actually trying to do it properly.
    Without balance, there could only be chaos.
    Without chaos, there could be no balance.
    I live with karma. Eat with destiny. Dream of life without shackles....
    Yet. If life had no consequences, life could not exist, nor could it flourish.


    If at first you dont succeed.You're screwed.

    C++/Java NOOB.

    I aint a professional at PHP, but if i can help i will.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width