|
-
Jun 29th, 2006, 07:39 AM
#1
Thread Starter
Frenzied Member
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.
-
Jun 29th, 2006, 08:04 AM
#2
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
-
Jun 29th, 2006, 09:00 AM
#3
Re: color
If you're using a <p> tag you don't need the <br>.
-
Jun 29th, 2006, 03:18 PM
#4
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.
-
Jun 29th, 2006, 03:44 PM
#5
Hyperactive Member
Re: color
 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.
-
Jun 29th, 2006, 03:52 PM
#6
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.
-
Jun 29th, 2006, 03:54 PM
#7
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.
-
Jun 29th, 2006, 04:24 PM
#8
Re: color
Further more, an XML document containing PHP programming instructions is a valid document and can be validated as such.
-
Jun 30th, 2006, 04:49 AM
#9
Thread Starter
Frenzied Member
Re: color
 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?
-
Jun 30th, 2006, 05:22 AM
#10
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.
-
Jul 1st, 2006, 03:05 AM
#11
Hyperactive Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|