By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,949 Members | 946 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,949 IT Pros & Developers. It's quick & easy.

PHP output / text markup

P: n/a
Hi there,

I have edited some php-source (a Stringychat 'shoutbox' on the webpage)
By default, all the text was not marked up at all.
I have tried to markup the text, and succeeded partly.

Can somebody help me applying my last changes?
This is the source:
printf("<font face=\"Verdana, Arial, Helvetica, sans-serif\"
size=\"-2\" color=\"#888888\">%s\n", date("H:i - d/m/y",
$myrow["StringyChat_time"]));
printf("<font face=\"Verdana, Arial, Helvetica, sans-serif\"
size=\"-2\" color=\"#888888\"><div class=\"StringyChatItem\">%s\n",
$myrow["StringyChat_name"]);
printf("%s<font face=\"Verdana, Arial, Helvetica, sans-serif\"
size=\"-1\" color=\"#ff0000\"></div>\n", $msg);

StringyChat_time = 22:18 - 05/01/05 ,
StringyChat_name = My name
msg = This is the message

the output on the screen is like this:

22:18 - 05/01/05
My name This is the message

It is all in gray, and all the same (good) font.
What I would like is that the time is same gray, same font
after that on a new row (like it is now) the name in bold black, behind that
a "-" and then the message in red (same font)

Could some PHP-expert please assist me with this?

Thanks, Jan K.
Jul 17 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Hello Jan,

I think you need to close the <font>-tag on each line, like:

printf("<font face=\"Verdana, Arial, Helvetica, sans-serif\"
size=\"-2\" color=\"#888888\">%s\n", date("H:i - d/m/y",
$myrow["StringyChat_time"])</font>" );

I do not have php available at this moment, so I have not tested it but I am
pretty sure.

Regards,

Stefan

Jan K. wrote:
Hi there,

I have edited some php-source (a Stringychat 'shoutbox' on the webpage)
By default, all the text was not marked up at all.
I have tried to markup the text, and succeeded partly.

Can somebody help me applying my last changes?
This is the source:
printf("<font face=\"Verdana, Arial, Helvetica, sans-serif\"
size=\"-2\" color=\"#888888\">%s\n", date("H:i - d/m/y",
$myrow["StringyChat_time"]));
printf("<font face=\"Verdana, Arial, Helvetica, sans-serif\"
size=\"-2\" color=\"#888888\"><div class=\"StringyChatItem\">%s\n",
$myrow["StringyChat_name"]);
printf("%s<font face=\"Verdana, Arial, Helvetica, sans-serif\"
size=\"-1\" color=\"#ff0000\"></div>\n", $msg);

StringyChat_time = 22:18 - 05/01/05 ,
StringyChat_name = My name
msg = This is the message

the output on the screen is like this:

22:18 - 05/01/05
My name This is the message

It is all in gray, and all the same (good) font.
What I would like is that the time is same gray, same font
after that on a new row (like it is now) the name in bold black, behind
that a "-" and then the message in red (same font)

Could some PHP-expert please assist me with this?

Thanks, Jan K.


Jul 17 '05 #2

P: n/a
ugh.. what a mess
you don't need a php expert...

how about:
echo '<font face="Verdana, Arial, Helvetica, sans-serif" size="-2"
color="#888888">'
..date('H:i - d/m/y',$myrow['StringyChat_time'])
..'<div class="StringyChatItem">'.$myrow["StringyChat_name"]
..' - <FONT color="red">'.msg.'</FONT></div>'
..'</FONT>';

toss all that printf mess... use single quotes so you don't have to
escape the double-quotes and php doesn't try to parse what's inside...
I have no idea how "StringChatItem" has been defined in the StyleSheet,
so that could change fonts/ colors, etc..

Jul 17 '05 #3

P: n/a
Your question is not about PHP, but about HTML (and CSS).
First define your otput HTML like:

<html>
<head>
<style type="text/css">
.base {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 80%;
color: #888888;
}
.StringyChatItem {
color: Black;
font-weight: bold;
}
</style>
</head>
<body>
<span class="base">
22:18 - 05/01/05<br />
<span class="StringyChatItem">My name -</span>
<span style="color: Red;">This is the message</span>
</span>
</body>
</html>

Then use PHP in it like:

<?php
$myrow['StringyChat_time'] = mktime( 22, 18, 0, 1, 5, 2005 );
$myrow['StringyChat_name'] = 'My name';
$msg = 'This is the message';
?>
<html>
<head>
<style type="text/css">
.base {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 80%;
color: #888888;
}
.StringyChatItem {
color: Black;
font-weight: bold;
}
</style>
</head>
<body>
<span class="base">
<?php echo date( "H:i - d/m/y", $myrow['StringyChat_time'] ); ?><br />
<span class="StringyChatItem"><?php echo htmlspecialchars( $myrow['StringyChat_name'] ); ?> -</span>
<span style="color: Red;"><?php echo htmlspecialchars( $msg ); ?></span>
</base>
</body>
</html>

Do not use <font> tags if you do not have to (use "class" and "style" attributes).
Remember that if you do not close tags ("font" or "div" etc.) then it'll "bleed"
styles to the rest of the document. So if you change font style, then close the tag
right after the text ending, to which the style applies. If you nest style modifying tags,
then remember that outer tag style may (in most cases will) influence inner tag style.

Hilarion
Jul 17 '05 #4

P: n/a
Hilarion wrote:
Your question is not about PHP, but about HTML (and CSS).
First define your otput HTML like:

<html>
<head>
<style type="text/css">
.base {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 80%;
color: #888888;
}
.StringyChatItem {
color: Black;
font-weight: bold;
}
</style>
</head>
<body>
<span class="base">
22:18 - 05/01/05<br />
<span class="StringyChatItem">My name -</span>
<span style="color: Red;">This is the message</span>
</span>
</body>
</html>

Then use PHP in it like:

<?php
$myrow['StringyChat_time'] = mktime( 22, 18, 0, 1, 5, 2005 );
$myrow['StringyChat_name'] = 'My name';
$msg = 'This is the message';

<html>
<head>
<style type="text/css">
.base {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 80%;
color: #888888;
}
.StringyChatItem {
color: Black;
font-weight: bold;
}
</style>
</head>
<body>
<span class="base">
<?php echo date( "H:i - d/m/y", $myrow['StringyChat_time'] );
?><br /> <span class="StringyChatItem"><?php echo
htmlspecialchars( $myrow['StringyChat_name'] ); ?> -</span>
<span style="color: Red;"><?php echo htmlspecialchars( $msg );
?></span> </base> </body>
</html>

Do not use <font> tags if you do not have to (use "class" and "style"
attributes). Remember that if you do not close tags ("font" or "div" etc.)
then
it'll "bleed" styles to the rest of the document. So if you change font
style, then
close the tag right after the text ending, to which the style applies. If
you nest
style modifying tags, then remember that outer tag style may (in most
cases will) influence
inner tag style.
Hilarion

Thanks, I'll take your tips into account.
Someone already helped me (in alt.php) but he/she did not crosspost, so you
did not see that reply.
We (in Holland) do not have a PHP-group, but I am trying to distinguis which
php-group is the best for me.
I have so little experience with PHP, but sometimes need to edit/change some
code for my webpage (PHP/MySQL).

So thanks for your help!

Jan K.
Jul 17 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.