how do i color that entry red guys?PHP Code:echo $row[0] . "=" . $row[1] . " " . $row[2] . " " . $row[3] . "<br>";
Printable View
how do i color that entry red guys?PHP Code:echo $row[0] . "=" . $row[1] . " " . $row[2] . " " . $row[3] . "<br>";
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)
and the php code would beHTML Code:<style>
.fontStyle{
font-color:#FF0000;}
</style>
HTHPHP Code:echo "<p class='fontStyle'>" . $row[0] . "=" . $row[1] . " " . $row[2] . " " . $row[3] . "</p><br>";
If you're using a <p> tag you don't need the <br>.
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.Code:<colorThatRed>My Red coloured Text</colorTheRed>
I have yet to find any evidence saying tahts its bad....Even Books do it.Quote:
Originally Posted by visualAd
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. ;)
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.
Further more, an XML document containing PHP programming instructions is a valid document and can be validated as such. :)
what should i use then mate?Quote:
Originally Posted by visualAd
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.
Hmm...I never knew that. Thanks..Pengate and VisualAd.
In my current project I'm actually trying to do it properly.