Forum Moderators: coopster

Message Too Old, No Replies

php echo-bold font

         

hiedler

5:34 pm on Apr 26, 2008 (gmt 0)

10+ Year Member



hi
I wrote script of calendar,and i want to make the names of people that have namesday bold...

<?php

$datum=date("j.n.Y");
echo "Dnes je ".$datum.", meniny má ";
$mesiac = explode(".", $datum);
$subor = "calendar/".$mesiac[1].".txt";
$dni=file($subor);
echo $dni[$mesiac[0]-1] ; //i want to write this bold
echo "<br />";
echo "<b> zajtra slávi </b>";
echo $dni[$mesiac[0]]; //and this also
?>
can somebody help me?

ashishp

6:00 pm on Apr 26, 2008 (gmt 0)

10+ Year Member



echo the complete HTML i.e:

echo "<B>".$dni[$mesiac[0]-1]."</b>" ;

This assumes you are viewing the output in a browser.

hiedler

7:15 pm on Apr 26, 2008 (gmt 0)

10+ Year Member



yeah it works...thanks
and dont you know,how can i change font color in
echo "<B>".$dni[$mesiac[0]-1]."</b>"
without using <p style...>

g1smd

7:26 pm on Apr 26, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Use CSS in a separate stylesheet.

Apply the style like this (assuming the bold words are inside a paragraph and the paragraph has a class name of "cal"):

<p class="cal">

.... <b> bold stuff here </b> ....

</p>

.

The CSS is very simple:

p.cal b { color: #7F7F7F };

.

The above code applies the style to somthing that is bold, but only when it is inside a paragraph and only if that paragraph has a class name of "cal".

.

You could do <b style="color: #7F7F7F"> but that would be an awful hack.

ag_47

12:39 am on Apr 27, 2008 (gmt 0)

10+ Year Member



or you can use <font color="red"> .. </font> although the font element was deprecated and is not supported in XHTML 1.0 Strict DTD.

Your best bet is CSS.. and a simple class, p.red{...}

g1smd

2:01 am on Apr 27, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



*** or you can use <font color="red"> ***

You could, but 1998 was a decade ago. ;-)

I haven't used a font tag in years.

g1smd

2:05 am on Apr 27, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



*** a simple class, p.red{...} ***

Don't name your class "red". Use what it *does* for the name, not what it looks like. If you later change the text colour, that class name would otherwise look silly.

You actually need a compound definition:

p.cal b { color: #7F7F7F }

hiedler

4:47 pm on Apr 27, 2008 (gmt 0)

10+ Year Member



thanks guys,for sure it gonna work,but i need to change just the colour withou using <p> tag, because i need it to be in the same line,or can I use CSS without <p> tag (i really dont know,cause am using Dreamweaber CS3,and it makes all code for me:) )
and if I have to use <font color...> how does it work? am trying to use it like this
echo "<font color="red">".$dni[$mesiac[0]-1]."</font>" ;
but only thing that happen is this on my site
Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in C:\wamp\www\Stranka\index.php on line 284
anybody knows where is the problem?

Receptional Andy

5:00 pm on Apr 27, 2008 (gmt 0)



The problem is that you have unescaped quotation marks:

"<font color=[5]"[/5]red[5]"[/5]>"

You need to escape them or use single quotes:

echo "<font color=[5]\"[/5]red[5]\"[/5]>".$dni[$mesiac[0]-1]."</font>" ; 

Or better still (as per g1smd's recommendation to use CSS):

echo '<span class="name">'.$dni[$mesiac[0]-1].'</span>'; 

hiedler

5:55 pm on Apr 27, 2008 (gmt 0)

10+ Year Member



yeah it works like this
echo '<span class="name">'.$dni[$mesiac[0]-1].'</span>';
:)
thanks to alô....especially to you andy...

g1smd

7:24 pm on Apr 27, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



The bold text is inside the <b> element, but that element must be inside some larger block.

Apply the style to that. Even if it were buried inside a list inside a table, you could still do it.

For example, you could apply the class name to the table tag and then use this:

table.cal tr td ul li b { color: #7F7F7F }

Look closely at the CSS. There is a space between the element names, not a comma. most people miss this special notation.